Skip to content

Commit 52a1e25

Browse files
gpsheadclaude
andcommitted
Fix failing tests when traceback timestamps are enabled
Update test_wsgiref, test_pdb, and test_remote_pdb to handle timestamp suffixes in exception messages when PYTHON_TRACEBACK_TIMESTAMPS is set. - test_wsgiref: Use traceback.strip_exc_timestamps() before comparing error messages in validation tests - test_pdb: Update doctest expected output to use ellipsis for timestamp matching in await support test - test_remote_pdb: Strip timestamps from stdout before comparison in do_test method All tests now pass both with and without timestamp functionality enabled. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent d0f95ba commit 52a1e25

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

Lib/test/test_pdb.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2200,7 +2200,7 @@ def test_pdb_await_support():
22002200
> <doctest test.test_pdb.test_pdb_await_support[2]>(4)main()
22012201
-> await pdb.Pdb(nosigint=True, readrc=False).set_trace_async()
22022202
(Pdb) await non_exist()
2203-
*** NameError: name 'non_exist' is not defined
2203+
*** NameError: name 'non_exist' is not defined...
22042204
> <doctest test.test_pdb.test_pdb_await_support[2]>(4)main()
22052205
-> await pdb.Pdb(nosigint=True, readrc=False).set_trace_async()
22062206
(Pdb) s

Lib/test/test_remote_pdb.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import tempfile
1212
import textwrap
1313
import threading
14+
import traceback
1415
import unittest
1516
import unittest.mock
1617
from contextlib import closing, contextmanager, redirect_stdout, redirect_stderr, ExitStack
@@ -207,9 +208,9 @@ def sigint_stdout_write(s):
207208
self.assertEqual(actual_outgoing, expected_outgoing)
208209
self.assertEqual(completions, expected_completions)
209210
if expected_stdout_substring and not expected_stdout:
210-
self.assertIn(expected_stdout_substring, stdout.getvalue())
211+
self.assertIn(expected_stdout_substring, traceback.strip_exc_timestamps(stdout.getvalue()))
211212
else:
212-
self.assertEqual(stdout.getvalue(), expected_stdout)
213+
self.assertEqual(traceback.strip_exc_timestamps(stdout.getvalue()), expected_stdout)
213214
input_mock.assert_has_calls([unittest.mock.call(p) for p in prompts])
214215
actual_state = {k: getattr(client, k) for k in expected_state}
215216
self.assertEqual(actual_state, expected_state)

Lib/test/test_wsgiref.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import os
1919
import re
2020
import signal
21+
import traceback
2122
import sys
2223
import threading
2324
import unittest
@@ -153,7 +154,7 @@ def bad_app(environ,start_response):
153154
b"A server error occurred. Please contact the administrator."
154155
)
155156
self.assertEqual(
156-
err.splitlines()[-2],
157+
traceback.strip_exc_timestamps(err).splitlines()[-2],
157158
"AssertionError: Headers (('Content-Type', 'text/plain')) must"
158159
" be of type list: <class 'tuple'>"
159160
)
@@ -177,7 +178,7 @@ def bad_app(environ, start_response):
177178
self.assertEndsWith(out,
178179
b"A server error occurred. Please contact the administrator."
179180
)
180-
self.assertEqual(err.splitlines()[-2], exc_message)
181+
self.assertEqual(traceback.strip_exc_timestamps(err).splitlines()[-2], exc_message)
181182

182183
def test_wsgi_input(self):
183184
def bad_app(e,s):
@@ -189,7 +190,7 @@ def bad_app(e,s):
189190
b"A server error occurred. Please contact the administrator."
190191
)
191192
self.assertEqual(
192-
err.splitlines()[-2], "AssertionError"
193+
traceback.strip_exc_timestamps(err).splitlines()[-2], "AssertionError"
193194
)
194195

195196
def test_bytes_validation(self):

0 commit comments

Comments
 (0)