From 677046626609e888f28b3ec363931edaed4ceea0 Mon Sep 17 00:00:00 2001 From: Jon Dufresne Date: Mon, 7 Dec 2020 12:26:14 -0800 Subject: [PATCH] =?UTF-8?q?Add=20coverage=20for=20"if=20not=20is=5Fpinned?= =?UTF-8?q?=5Frequirement(=E2=80=A6)"=20in=20get=5Fhashes()?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This line is untested and so frequently appears as uncovered during coverage analysis, erroneously marking the PR with a big red x when the PR is otherwise green. --- tests/test_repository_pypi.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/test_repository_pypi.py b/tests/test_repository_pypi.py index b0b74d6c8..dd18d9a2b 100644 --- a/tests/test_repository_pypi.py +++ b/tests/test_repository_pypi.py @@ -66,6 +66,14 @@ def test_get_hashes_editable_empty_set(from_editable, pypi_repository): assert pypi_repository.get_hashes(ireq) == set() +def test_get_hashes_unpinned_raises(from_line, pypi_repository): + # Under normal pip-tools usage, get_hashes() should never be called with an + # unpinned requirement. The TypeError represents a programming mistake. + ireq = from_line("django") + with pytest.raises(TypeError, match=r"^Expected pinned requirement, got django"): + pypi_repository.get_hashes(ireq) + + @pytest.mark.parametrize(("content", "content_length"), ((b"foo", 3), (b"foobar", 6))) def test_open_local_or_remote_file__local_file(tmp_path, content, content_length): """