From dd0c393b4599a6becdb0c1084002c050434984e6 Mon Sep 17 00:00:00 2001 From: NakanoMiku Date: Sun, 24 Dec 2023 04:03:20 +0800 Subject: [PATCH] Update test_bdb.py from CPython v3.12.0 --- Lib/test/test_bdb.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/Lib/test/test_bdb.py b/Lib/test/test_bdb.py index 70cb096e9..a3abbbb8d 100644 --- a/Lib/test/test_bdb.py +++ b/Lib/test/test_bdb.py @@ -59,6 +59,7 @@ from contextlib import contextmanager from itertools import islice, repeat from test.support import import_helper from test.support import os_helper +from test.support import patch_list class BdbException(Exception): pass @@ -432,8 +433,9 @@ class TracerRun(): not_empty = '' if self.tracer.set_list: not_empty += 'All paired tuples have not been processed, ' - not_empty += ('the last one was number %d' % + not_empty += ('the last one was number %d\n' % self.tracer.expect_set_no) + not_empty += repr(self.tracer.set_list) # Make a BdbNotExpectedError a unittest failure. if type_ is not None and issubclass(BdbNotExpectedError, type_): @@ -728,6 +730,14 @@ class StateTestCase(BaseTestCase): def test_skip(self): # Check that tracing is skipped over the import statement in # 'tfunc_import()'. + + # Remove all but the standard importers. + sys.meta_path[:] = ( + item + for item in sys.meta_path + if item.__module__.startswith('_frozen_importlib') + ) + code = """ def main(): lno = 3 @@ -1224,5 +1234,12 @@ class IssuesTestCase(BaseTestCase): tracer.runcall(tfunc_import) +class TestRegressions(unittest.TestCase): + def test_format_stack_entry_no_lineno(self): + # See gh-101517 + self.assertIn('Warning: lineno is None', + Bdb().format_stack_entry((sys._getframe(), None))) + + if __name__ == "__main__": unittest.main()