]> granicus.if.org Git - python/commitdiff
Make test_warnings play nice with regrtest -R:: now that regrtest doesn't
authorThomas Wouters <thomas@python.org>
Sun, 16 Apr 2006 15:43:39 +0000 (15:43 +0000)
committerThomas Wouters <thomas@python.org>
Sun, 16 Apr 2006 15:43:39 +0000 (15:43 +0000)
always reload the module (specifically, it doesn't reload if the module has
a 'test_main'.)

Lib/test/test_warnings.py

index 5a3f5216310e933a24086af2f0da0c862d02859f..5d051a59d1b6e0d957cbbe4bccb44b01b9c24ac4 100644 (file)
@@ -82,11 +82,11 @@ class TestModule(unittest.TestCase):
         self.assertEqual(msg.category, 'UserWarning')
 
 def test_main(verbose=None):
+    # Obscure hack so that this test passes after reloads or repeated calls
+    # to test_main (regrtest -R).
+    if '__warningregistry__' in globals():
+        del globals()['__warningregistry__']
     test_support.run_unittest(TestModule)
 
-# Obscure hack so that this test passes after reloads (regrtest -R).
-if '__warningregistry__' in globals():
-    del globals()['__warningregistry__']
-
 if __name__ == "__main__":
     test_main(verbose=True)