Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a test for uncovered branch in the writer module #1101

Merged
merged 1 commit into from
Apr 10, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions tests/test_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,28 @@ def test_iter_lines__hash_missing(writer, from_line):
assert tuple(lines) == expected_lines


def test_iter_lines__no_warn_if_only_unhashable_packages(writer, from_line):
"""
There shouldn't be MESSAGE_UNHASHED_PACKAGE warning if there are only unhashable
packages. See GH-1101.
"""
writer.allow_unsafe = False
writer.emit_header = False
ireqs = [
from_line("file:///unhashable-pkg1/#egg=unhashable-pkg1"),
from_line("file:///unhashable-pkg2/#egg=unhashable-pkg2"),
]
hashes = {ireq: set() for ireq in ireqs}

lines = writer._iter_lines(ireqs, hashes=hashes)

expected_lines = (
"file:///unhashable-pkg1/#egg=unhashable-pkg1",
"file:///unhashable-pkg2/#egg=unhashable-pkg2",
)
assert tuple(lines) == expected_lines


def test_write_header(writer):
expected = map(
comment,
Expand Down