コード例 #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
ファイル: test_pipfreeze.py プロジェクト: msabramo/defrost
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
ファイル: test_pipfreeze.py プロジェクト: pombredanne/defrost
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
ファイル: test_pipfreeze.py プロジェクト: pombredanne/defrost
def test_pip_freeze__getitems_found(freeze, package, expected):
    from defrost import PipFreeze
    pip_freeze = PipFreeze(freeze)
    assert pip_freeze[package] == expected
コード例 #11
0
ファイル: test_pipfreeze.py プロジェクト: pombredanne/defrost
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