Skip to content

Commit

Permalink
Merge pull request #3563 from asottile/undetermined_location_none
Browse files Browse the repository at this point in the history
Print <undetermined location> instead of None for warnings
  • Loading branch information
nicoddemus authored Jun 10, 2018
2 parents fe81de6 + 49f621d commit 1170504
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions changelog/3563.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Warnings without ``location`` were reported as ``None``. This is corrected to now report ``<undetermined location>``.
2 changes: 1 addition & 1 deletion src/_pytest/terminal.py
Original file line number Diff line number Diff line change
Expand Up @@ -682,7 +682,7 @@ def summary_warnings(self):

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)
Expand Down
5 changes: 4 additions & 1 deletion testing/test_terminal.py
Original file line number Diff line number Diff line change
Expand Up @@ -1025,7 +1025,10 @@ def pytest_terminal_summary(terminalreporter):
"""
)
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(
Expand Down

0 comments on commit 1170504

Please sign in to comment.