当前位置: 首页>>代码示例>>Python>>正文


Python InstallRequirement.from_line方法代码示例

本文整理汇总了Python中pip.req.req_install.InstallRequirement.from_line方法的典型用法代码示例。如果您正苦于以下问题:Python InstallRequirement.from_line方法的具体用法?Python InstallRequirement.from_line怎么用?Python InstallRequirement.from_line使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pip.req.req_install.InstallRequirement的用法示例。


在下文中一共展示了InstallRequirement.from_line方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_install_default

# 需要导入模块: from pip.req.req_install import InstallRequirement [as 别名]
# 或者: from pip.req.req_install.InstallRequirement import from_line [as 别名]
def test_install_default(mocker, check_output):
    resolve = mocker.patch('piptools.resolver.Resolver.resolve')
    reverse_dependencies = mocker.patch('piptools.resolver.Resolver.reverse_dependencies')
    resolve.return_value = [InstallRequirement.from_line('pendulum==1.2.0')]
    reverse_dependencies.return_value = {}
    app = Application()
    app.add(InstallCommand())

    command = app.find('install')
    command_tester = CommandTester(command)
    command_tester.execute([('command', command.name), ('--no-progress', True)])

    assert os.path.exists(DUMMY_LOCK)
    os.remove(DUMMY_LOCK)

    check_output.assert_called_once()

    output = command_tester.get_display()
    expected = """
Locking dependencies to poetry.lock

 - Resolving dependencies
 - Writing dependencies

Installing dependencies

 - Installing pendulum (1.2.0)
"""

    assert output == expected 
开发者ID:sdispater,项目名称:poet,代码行数:32,代码来源:test_install.py

示例2: test_update_only_update

# 需要导入模块: from pip.req.req_install import InstallRequirement [as 别名]
# 或者: from pip.req.req_install.InstallRequirement import from_line [as 别名]
def test_update_only_update(mocker):
    sub = mocker.patch('subprocess.check_output')
    resolve = mocker.patch('piptools.resolver.Resolver.resolve')
    get_hashes = mocker.patch('piptools.resolver.Resolver.resolve_hashes')
    reverse_dependencies = mocker.patch('piptools.resolver.Resolver.reverse_dependencies')
    reverse_dependencies.return_value = {}
    write_lock = mocker.patch('poet.installer.Installer._write_lock')
    pendulum_req = InstallRequirement.from_line('pendulum==1.3.0')
    pytest_req = InstallRequirement.from_line('pytest==3.5.0')
    resolve.return_value = [
        pendulum_req,
        pytest_req
    ]
    get_hashes.return_value = {
        pendulum_req: set([
            "sha256:a97e3ed9557ac0c5c3742f21fa4d852d7a050dd9b1b517e993aebef2dd2eea52",
            "sha256:641140a05f959b37a177866e263f6f53a53b711fae6355336ee832ec1a59da8a"
        ]),
        pytest_req: set([
            "sha256:66f332ae62593b874a648b10a8cb106bfdacd2c6288ed7dec3713c3a808a6017",
            "sha256:b70696ebd1a5e6b627e7e3ac1365a4bc60aaf3495e843c1e70448966c5224cab"
        ])
    }
    app = Application()
    app.add(UpdateCommand())

    command = app.find('update')
    command_tester = CommandTester(command)
    command_tester.execute([('command', command.name), ('--no-progress', True)])

    assert sub.call_count == 2
    write_lock.assert_called_once()

    output = command_tester.get_display()
    expected = """
Updating dependencies

 - Resolving dependencies
 - Summary: 2 updates
 - Updating pendulum (1.2.0 -> 1.3.0)
 - Updating pytest (3.0.7 -> 3.5.0)
"""

    assert output == expected 
开发者ID:sdispater,项目名称:poet,代码行数:46,代码来源:test_update.py

示例3: test_update_specific_packages

# 需要导入模块: from pip.req.req_install import InstallRequirement [as 别名]
# 或者: from pip.req.req_install.InstallRequirement import from_line [as 别名]
def test_update_specific_packages(mocker):
    sub = mocker.patch('subprocess.check_output')
    resolve = mocker.patch('piptools.resolver.Resolver.resolve')
    get_hashes = mocker.patch('piptools.resolver.Resolver.resolve_hashes')
    reverse_dependencies = mocker.patch('piptools.resolver.Resolver.reverse_dependencies')
    reverse_dependencies.return_value = {}
    write_lock = mocker.patch('poet.installer.Installer._write_lock')
    pendulum_req = InstallRequirement.from_line('pendulum==1.3.0')
    pytest_req = InstallRequirement.from_line('pytest==3.5.0')
    resolve.return_value = [
        pendulum_req,
        pytest_req
    ]
    get_hashes.return_value = {
        pendulum_req: set([
            "sha256:a97e3ed9557ac0c5c3742f21fa4d852d7a050dd9b1b517e993aebef2dd2eea52",
            "sha256:641140a05f959b37a177866e263f6f53a53b711fae6355336ee832ec1a59da8a"
        ]),
        pytest_req: set([
            "sha256:66f332ae62593b874a648b10a8cb106bfdacd2c6288ed7dec3713c3a808a6017",
            "sha256:b70696ebd1a5e6b627e7e3ac1365a4bc60aaf3495e843c1e70448966c5224cab"
        ])
    }
    app = Application()
    app.add(UpdateCommand())

    command = app.find('update')
    command_tester = CommandTester(command)
    command_tester.execute([('command', command.name), ('packages', ['pendulum']), ('--no-progress', True)])

    assert sub.call_count == 1
    write_lock.assert_called_once()

    output = command_tester.get_display()
    expected = """
Updating dependencies

 - Resolving dependencies
 - Summary: 1 updates
 - Updating pendulum (1.2.0 -> 1.3.0)
"""

    assert output == expected 
开发者ID:sdispater,项目名称:poet,代码行数:45,代码来源:test_update.py

示例4: test_update_with_new_packages

# 需要导入模块: from pip.req.req_install import InstallRequirement [as 别名]
# 或者: from pip.req.req_install.InstallRequirement import from_line [as 别名]
def test_update_with_new_packages(mocker):
    sub = mocker.patch('subprocess.check_output')
    resolve = mocker.patch('piptools.resolver.Resolver.resolve')
    get_hashes = mocker.patch('piptools.resolver.Resolver.resolve_hashes')
    reverse_dependencies = mocker.patch('piptools.resolver.Resolver.reverse_dependencies')
    reverse_dependencies.return_value = {'requests': set()}
    write_lock = mocker.patch('poet.installer.Installer._write_lock')
    pendulum_req = InstallRequirement.from_line('pendulum==1.3.0')
    pytest_req = InstallRequirement.from_line('pytest==3.5.0')
    requests_req = InstallRequirement.from_line('requests==2.13.0')
    resolve.return_value = [
        pendulum_req,
        pytest_req,
        requests_req
    ]
    get_hashes.return_value = {
        pendulum_req: set([
            "sha256:a97e3ed9557ac0c5c3742f21fa4d852d7a050dd9b1b517e993aebef2dd2eea52",
            "sha256:641140a05f959b37a177866e263f6f53a53b711fae6355336ee832ec1a59da8a"
        ]),
        pytest_req: set([
            "sha256:66f332ae62593b874a648b10a8cb106bfdacd2c6288ed7dec3713c3a808a6017",
            "sha256:b70696ebd1a5e6b627e7e3ac1365a4bc60aaf3495e843c1e70448966c5224cab"
        ]),
        requests_req: set([
            "sha256:5722cd09762faa01276230270ff16af7acf7c5c45d623868d9ba116f15791ce8",
            "sha256:1a720e8862a41aa22e339373b526f508ef0c8988baf48b84d3fc891a8e237efb"
        ])
    }
    app = Application()
    app.add(UpdateCommand())

    command = app.find('update')
    command_tester = CommandTester(command)
    command_tester.execute([('command', command.name), ('--no-progress', True)])

    assert sub.call_count == 3
    write_lock.assert_called_once()

    output = command_tester.get_display()
    expected = """
Updating dependencies

 - Resolving dependencies
 - Summary: 2 updates, 1 installations
 - Updating pendulum (1.2.0 -> 1.3.0)
 - Updating pytest (3.0.7 -> 3.5.0)
 - Installing requests (2.13.0)
"""

    assert output == expected 
开发者ID:sdispater,项目名称:poet,代码行数:53,代码来源:test_update.py

示例5: test_update_with_no_updates

# 需要导入模块: from pip.req.req_install import InstallRequirement [as 别名]
# 或者: from pip.req.req_install.InstallRequirement import from_line [as 别名]
def test_update_with_no_updates(mocker):
    sub = mocker.patch('subprocess.check_output')
    resolve = mocker.patch('piptools.resolver.Resolver.resolve')
    get_hashes = mocker.patch('piptools.resolver.Resolver.resolve_hashes')
    reverse_dependencies = mocker.patch('piptools.resolver.Resolver.reverse_dependencies')
    reverse_dependencies.return_value = {}
    write_lock = mocker.patch('poet.installer.Installer._write_lock')
    pendulum_req = InstallRequirement.from_line('pendulum==1.2.0')
    pytest_req = InstallRequirement.from_line('pytest==3.0.7')
    resolve.return_value = [
        pendulum_req,
        pytest_req
    ]
    get_hashes.return_value = {
        pendulum_req: set([
            "sha256:a97e3ed9557ac0c5c3742f21fa4d852d7a050dd9b1b517e993aebef2dd2eea52",
            "sha256:641140a05f959b37a177866e263f6f53a53b711fae6355336ee832ec1a59da8a"
        ]),
        pytest_req: set([
            "sha256:66f332ae62593b874a648b10a8cb106bfdacd2c6288ed7dec3713c3a808a6017",
            "sha256:b70696ebd1a5e6b627e7e3ac1365a4bc60aaf3495e843c1e70448966c5224cab"
        ])
    }
    app = Application()
    app.add(UpdateCommand())

    command = app.find('update')
    command_tester = CommandTester(command)
    command_tester.execute([('command', command.name), ('--no-progress', True)])

    assert sub.call_count == 0
    assert write_lock.call_count == 0

    output = command_tester.get_display()
    expected = """
Updating dependencies

 - Resolving dependencies
 - Dependencies already up-to-date!
"""

    assert output == expected 
开发者ID:sdispater,项目名称:poet,代码行数:44,代码来源:test_update.py


注:本文中的pip.req.req_install.InstallRequirement.from_line方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。