]> granicus.if.org Git - python/commitdiff
Issue #23029: Fix catch_warnings() in test_filename_none
authorBerker Peksag <berker.peksag@gmail.com>
Sat, 16 Apr 2016 19:16:05 +0000 (22:16 +0300)
committerBerker Peksag <berker.peksag@gmail.com>
Sat, 16 Apr 2016 19:16:05 +0000 (22:16 +0300)
It was printed UserWarning output because catch_warnings() was missing
record=True.

Lib/test/test_warnings.py

index 11dc29408ae3917c10f3cda42d6bf7300f274cd2..bc7e39847420f9fff709b4abf23766fd5a9d1ab7 100644 (file)
@@ -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