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) == {}
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 == {}
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 == {}
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 == {}
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)}
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")}
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) == {}
def test_empty(self, pip_freeze, tmpdir): pip_freeze.return_value = [""] requirements_path = create_file(tmpdir, "requirements.txt", "") assert get_mismatches(requirements_path) == {}
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) == {}
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)}
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")}
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) == {}
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')}