Kaydet (Commit) ccff2bbd authored tarafından Berker Peksag's avatar Berker Peksag

Issue #23029: Fix catch_warnings() in test_filename_none

It was printed UserWarning output because catch_warnings() was missing
record=True.
üst aeff57d3
......@@ -553,10 +553,13 @@ class _WarningsTests(BaseTest):
globals_dict = globals()
oldfile = globals_dict['__file__']
try:
with original_warnings.catch_warnings(module=self.module) as w:
with original_warnings.catch_warnings(module=self.module, record=True) as w:
self.module.filterwarnings("always", category=UserWarning)
globals_dict['__file__'] = None
self.module.warn('test', UserWarning)
self.assertEqual(len(w), 1)
self.assertEqual(w[0].category, UserWarning)
self.assertEqual(str(w[0].message), 'test')
finally:
globals_dict['__file__'] = oldfile
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment