From: Thomas Wouters Date: Sun, 16 Apr 2006 15:43:39 +0000 (+0000) Subject: Make test_warnings play nice with regrtest -R:: now that regrtest doesn't X-Git-Tag: v2.5a2~192 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=767833dc228c9475cd52b99ee8e03793d31d7a81;p=python Make test_warnings play nice with regrtest -R:: now that regrtest doesn't always reload the module (specifically, it doesn't reload if the module has a 'test_main'.) --- diff --git a/Lib/test/test_warnings.py b/Lib/test/test_warnings.py index 5a3f521631..5d051a59d1 100644 --- a/Lib/test/test_warnings.py +++ b/Lib/test/test_warnings.py @@ -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)