Merge pull request #3563 from asottile/undetermined_location_none

Print <undetermined location> instead of None for warnings
This commit is contained in:
Bruno Oliveira 2018-06-10 16:19:50 -03:00 committed by GitHub
commit 11705040ac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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)
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:
lines = w.message.splitlines()
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.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(