Print <undetermined location> instead of None for warnings

This commit is contained in:
Anthony Sottile 2018-06-10 10:51:36 -07:00
parent 80f8a3ad7c
commit 49f621de76
3 changed files with 6 additions and 2 deletions

View File

@ -0,0 +1 @@
Warnings without ``location`` were reported as ``None``. This is corrected to now report ``<undetermined location>``.

View File

@ -682,7 +682,7 @@ class TerminalReporter(object):
self.write_sep("=", "warnings summary", yellow=True, bold=False) self.write_sep("=", "warnings summary", yellow=True, bold=False)
for location, warning_records in grouped: for location, warning_records in grouped:
self._tw.line(str(location) or "<undetermined location>") self._tw.line(str(location) if location else "<undetermined location>")
for w in warning_records: for w in warning_records:
lines = w.message.splitlines() lines = w.message.splitlines()
indented = "\n".join(" " + x for x in lines) indented = "\n".join(" " + x for x in lines)

View File

@ -1025,7 +1025,10 @@ def test_terminal_summary_warnings_are_displayed(testdir):
""" """
) )
result = testdir.runpytest("-rw") result = testdir.runpytest("-rw")
result.stdout.fnmatch_lines(["*internal warning", "*== 1 warnings in *"]) result.stdout.fnmatch_lines(
["<undetermined location>", "*internal warning", "*== 1 warnings in *"]
)
assert "None" not in result.stdout.str()
@pytest.mark.parametrize( @pytest.mark.parametrize(