Skip to content

Commit

Permalink
Add coverage for "if not is_pinned_requirement(…)" in get_hashes()
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jdufresne committed Dec 8, 2020
1 parent e76ab99 commit 6770466
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions tests/test_repository_pypi.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
"""
Expand Down

0 comments on commit 6770466

Please sign in to comment.