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

Print <undetermined location> instead of None for warnings #3563

Merged
merged 1 commit into from
Jun 10, 2018
Merged
Show file tree
Hide file tree
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
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