def test_mismatches(self, get_mismatches, capsys):
        get_mismatches.return_value = {'package1': ('1.1', '1.0'), 'package2': ('1.0', None)}
        with pytest.raises(SystemExit):
            check_requirements('requirements.txt')

        _, err = capsys.readouterr()
        assert 'package1 has version 1.1 but you have version 1.0 installed' in err
        assert 'package2 is in requirements.txt but not in virtualenv' in err
Exemple #2
0
    def test_mismatches(self, get_mismatches, capsys):
        get_mismatches.return_value = {
            "package1": ("1.1", "1.0"),
            "package2": ("1.0", None),
        }
        with pytest.raises(SystemExit):
            check_requirements("requirements.txt")

        _, err = capsys.readouterr()
        assert "package1 has version 1.1 but you have version 1.0 installed" in err
        assert "package2 is in requirements.txt but not in virtualenv" in err
Exemple #3
0
    def __init__(self):
        if not (sys.version_info[:2] == (2, 7) or sys.version_info[:2]
                == (3, 5) or sys.version_info[:2] == (3, 6)):
            print(
                'Your runtime Python environment is not supported. Check README.rst for more information how to set it up',
                file=sys.stderr)
            sys.exit(1)

        if not HAVE_PIP_LOCK:
            print(
                'The pip-lock is not installed, unable to validate environment. Check README.rst for more information',
                file=sys.stderr)
            sys.exit(1)

        check_requirements(
            os.path.abspath(os.path.join(module_dir, '../',
                                         'requirements.txt')),
            post_text=
            '\nRun the following on your machine: \n\n\tpip install -r requirements.txt\n'
        )
Exemple #4
0
 def test_relative_requirements_file(self, monkeypatch, tmp_path):
     monkeypatch.chdir(tmp_path)
     requirements = tmp_path / "requirements.txt"
     requirements.write_text("package==1.2\n")
     with mock_get_distributions({"package": "1.2"}):
         check_requirements("requirements.txt")
Exemple #5
0
 def test_no_mismatches(self, get_mismatches):
     get_mismatches.return_value = {}
     check_requirements("requirements.txt")
Exemple #6
0
 def test_relative_requirements_file(self, pip_freeze, tmpdir):
     pip_freeze.return_value = ["package==1.2"]
     create_file(tmpdir, "requirements.txt", "package==1.2")
     with tmpdir.as_cwd():
         check_requirements("requirements.txt")
 def test_relative_requirements_file(self, pip_freeze, tmpdir):
     pip_freeze.return_value = ['package==1.2']
     create_file(tmpdir, 'requirements.txt', 'package==1.2')
     with tmpdir.as_cwd():
         check_requirements('requirements.txt')