예제 #1
0
    def test_package_with_extra(self, pip_freeze, tmpdir):
        pip_freeze.return_value = ["package==1.1"]
        requirements_path = create_file(
            tmpdir, "requirements.txt", "package[anextra]==1.1"
        )

        assert get_mismatches(requirements_path) == {}
예제 #2
0
    def test_package_with_extra(self, tmp_path):
        requirements = tmp_path / "requirements.txt"
        requirements.write_text("package[anextra]==1.1\n")

        with mock_get_distributions({"package": "1.1"}):
            result = get_mismatches(str(requirements))

        assert result == {}
예제 #3
0
    def test_empty(self, tmp_path):
        requirements = tmp_path / "requirements.txt"
        requirements.write_text("\n")

        with mock_get_distributions({}):
            result = get_mismatches(str(requirements))

        assert result == {}
예제 #4
0
    def test_no_mismatches_case_insensitive(self, tmp_path):
        requirements = tmp_path / "requirements.txt"
        requirements.write_text("package==1.1\n")

        with mock_get_distributions({"Package": "1.1"}):
            result = get_mismatches(str(requirements))

        assert result == {}
예제 #5
0
    def test_missing(self, tmp_path):
        requirements = tmp_path / "requirements.txt"
        requirements.write_text("package==1.1\n")

        with mock_get_distributions({}):
            result = get_mismatches(str(requirements))

        assert result == {"package": ("1.1", None)}
예제 #6
0
    def test_version_mismatch(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.1"}):
            result = get_mismatches("requirements.txt")

        assert result == {"package": ("1.2", "1.1")}
예제 #7
0
    def test_editable_packages(self, pip_freeze, tmpdir):
        pip_freeze.return_value = [
            (
                "-e [email protected]:adamchainz/pip-lock.git@"
                + "efac0eef8072d73b001b1bae0731c1d58790ac4b#egg=pip-lock"
            ),
            "package==1.1",
        ]
        requirements_path = create_file(tmpdir, "requirements.txt", "package==1.1")

        assert get_mismatches(requirements_path) == {}
예제 #8
0
    def test_empty(self, pip_freeze, tmpdir):
        pip_freeze.return_value = [""]
        requirements_path = create_file(tmpdir, "requirements.txt", "")

        assert get_mismatches(requirements_path) == {}
예제 #9
0
    def test_no_mismatches_case_insensitive(self, pip_freeze, tmpdir):
        pip_freeze.return_value = ["Package==1.1"]
        requirements_path = create_file(tmpdir, "requirements.txt", "package==1.1")

        assert get_mismatches(requirements_path) == {}
예제 #10
0
    def test_missing(self, pip_freeze, tmpdir):
        pip_freeze.return_value = [""]
        requirements_path = create_file(tmpdir, "requirements.txt", "package==1.1")

        assert get_mismatches(requirements_path) == {"package": ("1.1", None)}
예제 #11
0
 def test_relative_requirements_file(self, pip_freeze, tmpdir):
     pip_freeze.return_value = ["package==1.1"]
     create_file(tmpdir, "requirements.txt", "package==1.2")
     with tmpdir.as_cwd():
         assert get_mismatches("requirements.txt") == {"package": ("1.2", "1.1")}
예제 #12
0
    def test_no_mismatches(self, pip_freeze, tmpdir):
        pip_freeze.return_value = ['package==1.1']
        requirements_path = create_file(tmpdir, 'requirements.txt', 'package==1.1')

        assert get_mismatches(requirements_path) == {}
예제 #13
0
 def test_relative_requirements_file(self, pip_freeze, tmpdir):
     pip_freeze.return_value = ['package==1.1']
     create_file(tmpdir, 'requirements.txt', 'package==1.2')
     with tmpdir.as_cwd():
         assert get_mismatches('requirements.txt') == {'package': ('1.2', '1.1')}