示例#1
0
def defrost(exit_mode, requirement_file, pip_freeze_file):
    """
    Check if the output of pip freeze satisfies the YAML requirement file. The
    pip freeze output may be passed as stdin:

        pip freeze | defrost reqs.yml -

    """
    reqs = _parse_yaml(requirement_file)
    pip_freeze = PipFreeze(pip_freeze_file.read())
    pip_freeze.load_requirements(reqs)

    exit_code = 0
    for package in pip_freeze.deprecated:
        click.echo("{}: {!r} does not satisfy {!r}: {}".format(
            package.deprecation_severity,
            package,
            package.deprecated_by,
            package.deprecation_reason,
        ),
                   err=True)
        if exit_code == 0:
            exit_code = exit_codes[package.deprecation_severity][exit_mode]

    sys.exit(exit_code)
示例#2
0
def test_pip_freeze__load_requirements(freeze, reqs, expected_deprecated):
    from defrost import PipFreeze
    pip_freeze = PipFreeze(freeze)
    pip_freeze.load_requirements(reqs)
    assert len(pip_freeze.deprecated) == len(expected_deprecated)
    for package, (pin, reason, severity) in zip(pip_freeze.deprecated, expected_deprecated):
        assert package.deprecated is True
        assert str(package) == pin
        assert package.deprecation_reason == reason
        assert package.deprecation_severity == severity
示例#3
0
def test_pip_freeze__load_requirements(freeze, reqs, expected_deprecated):
    from defrost import PipFreeze
    pip_freeze = PipFreeze(freeze)
    pip_freeze.load_requirements(reqs)
    assert len(pip_freeze.deprecated) == len(expected_deprecated)
    for package, (pin, reason, severity) in zip(pip_freeze.deprecated,
                                                expected_deprecated):
        assert package.deprecated is True
        assert str(package) == pin
        assert package.deprecation_reason == reason
        assert package.deprecation_severity == severity
示例#4
0
文件: cli.py 项目: msabramo/defrost
def defrost(exit_mode, requirement_file, pip_freeze_file):
    """
    Check if the output of pip freeze satisfies the YAML requirement file. The
    pip freeze output may be passed as stdin:

        pip freeze | defrost reqs.yml -

    """
    reqs = _parse_yaml(requirement_file)
    pip_freeze = PipFreeze(pip_freeze_file.read())
    pip_freeze.load_requirements(reqs)

    exit_code = 0
    for package in pip_freeze.deprecated:
        click.echo("{}: {!r} does not satisfy {!r}: {}".format(
            package.deprecation_severity,
            package,
            package.deprecated_by,
            package.deprecation_reason,
        ), err=True)
        if exit_code == 0:
            exit_code = exit_codes[package.deprecation_severity][exit_mode]

    sys.exit(exit_code)
示例#5
0
def test_pip_freeze__contains(freeze, package, expected):
    from defrost import PipFreeze
    pip_freeze = PipFreeze(freeze)
    assert (package in pip_freeze) is expected
示例#6
0
def test_pip_freeze__len(freeze, expected):
    from defrost import PipFreeze
    pip_freeze = PipFreeze(freeze)
    assert len(pip_freeze) == expected
示例#7
0
def test_pip_freeze__iter(freeze, expected):
    from defrost import PipFreeze
    pip_freeze = PipFreeze(freeze)
    assert list(pip_freeze) == expected
示例#8
0
def test_pip_freeze__bool(freeze, expected):
    from defrost import PipFreeze
    pip_freeze = PipFreeze(freeze)
    assert bool(pip_freeze) is expected
示例#9
0
def test_pip_freeze__getitems_KeyError(freeze, package):
    from defrost import PipFreeze
    pip_freeze = PipFreeze(freeze)
    pytest.raises(KeyError, pip_freeze.__getitem__, package)
示例#10
0
def test_pip_freeze__getitems_found(freeze, package, expected):
    from defrost import PipFreeze
    pip_freeze = PipFreeze(freeze)
    assert pip_freeze[package] == expected
示例#11
0
def test_pip_freeze__get_with_default(freeze, package, default, expected):
    from defrost import PipFreeze
    pip_freeze = PipFreeze(freeze)
    assert pip_freeze.get(package, default) == expected
示例#12
0
def test_pip_freeze__get_without_default(freeze, package, expected):
    from defrost import PipFreeze
    pip_freeze = PipFreeze(freeze)
    assert pip_freeze.get(package) == expected