summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorBerker Peksag <berker.peksag@gmail.com>2016-04-16 19:16:05 (GMT)
committerBerker Peksag <berker.peksag@gmail.com>2016-04-16 19:16:05 (GMT)
commitccff2bbd3b3e5376333792b629029ebb69a903d6 (patch)
tree9d1d17dd4683ffb63dc095f7362cffea61dac589 /Lib
parentaeff57d34aa60860f6c4e12bfd741d5c92d16dc3 (diff)
downloadcpython-ccff2bbd3b3e5376333792b629029ebb69a903d6.zip
cpython-ccff2bbd3b3e5376333792b629029ebb69a903d6.tar.gz
cpython-ccff2bbd3b3e5376333792b629029ebb69a903d6.tar.bz2
Issue #23029: Fix catch_warnings() in test_filename_none
It was printed UserWarning output because catch_warnings() was missing record=True.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_warnings.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/Lib/test/test_warnings.py b/Lib/test/test_warnings.py
index 11dc294..bc7e398 100644
--- a/Lib/test/test_warnings.py
+++ b/Lib/test/test_warnings.py
@@ -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