Skip to content

Commit 7f30217

Browse files
committed
fix tests
1 parent c78f84b commit 7f30217

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

src/_pytest/unraisableexception.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -75,25 +75,22 @@ def collect_unraisable() -> None:
7575
err_msg = meta.unraisable.err_msg
7676
else:
7777
err_msg = "Exception ignored in"
78-
msg = f"{err_msg}: {meta.object_repr}"
78+
summary = f"{err_msg}: {meta.object_repr}"
7979
traceback_message = "\n\n" + "".join(
8080
traceback.format_exception(
8181
meta.unraisable.exc_type,
8282
meta.unraisable.exc_value,
8383
meta.unraisable.exc_traceback,
8484
)
8585
)
86+
msg = summary + traceback_message + meta.tracemalloc_tb
8687
try:
87-
warnings.warn(
88-
pytest.PytestUnraisableExceptionWarning(
89-
msg + traceback_message + meta.tracemalloc_tb
90-
)
91-
)
88+
warnings.warn(pytest.PytestUnraisableExceptionWarning(msg))
9289
except pytest.PytestUnraisableExceptionWarning as e:
9390
# exceptions have a better way to show the traceback, but
9491
# warnings do not, so hide the traceback from the msg and
9592
# set the cause so the traceback shows up in the right place
96-
e.args = (msg + meta.tracemalloc_tb,)
93+
e.args = (summary + meta.tracemalloc_tb,)
9794
e.__cause__ = meta.unraisable.exc_value
9895
errors.append(e)
9996

testing/test_unraisableexception.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ def test_2(): pass
3636
" ",
3737
" Traceback (most recent call last):",
3838
" ValueError: del is broken",
39-
" ",
39+
" Enable tracemalloc to get traceback where the object was allocated.",
40+
" See https* for more info.",
4041
" warnings.warn(pytest.PytestUnraisableExceptionWarning(msg))",
4142
]
4243
)
@@ -73,7 +74,8 @@ def test_2(): pass
7374
" ",
7475
" Traceback (most recent call last):",
7576
" ValueError: del is broken",
76-
" ",
77+
" Enable tracemalloc to get traceback where the object was allocated.",
78+
" See https* for more info.",
7779
" warnings.warn(pytest.PytestUnraisableExceptionWarning(msg))",
7880
]
7981
)
@@ -111,7 +113,8 @@ def test_2(): pass
111113
" ",
112114
" Traceback (most recent call last):",
113115
" ValueError: del is broken",
114-
" ",
116+
" Enable tracemalloc to get traceback where the object was allocated.",
117+
" See https* for more info.",
115118
" warnings.warn(pytest.PytestUnraisableExceptionWarning(msg))",
116119
]
117120
)

0 commit comments

Comments
 (0)