diff --git a/Lib/idlelib/idle_test/test_zdummy.py b/Lib/idlelib/idle_test/test_zdummy.py new file mode 100644 --- /dev/null +++ b/Lib/idlelib/idle_test/test_zdummy.py @@ -0,0 +1,24 @@ +'''A hack to delete sys.modules['warnings'] after idle tests are run because +PyShell and run modules monkeypatch it to show warnings 'the Idle way'. +This causes test_logging to fail. Deleting entry forces re-import. +But we only want to do this when running test suite with regrtest, +not when running rests within Idle itself with unittest. +Both unittest and regrtest sort testcases by file and testcase name. +''' +import sys +import test.support +import unittest + +print('In zdummy, ts.use_resources=', test.support.use_resources) +def tearDownModule(): + if test.support.use_resources is not None: # changed to list by regrtest + del sys.modules['_warnings'] + del sys.modules['warnings'] + print('in tesrdown') + +class Zdummy(unittest.TestCase): + def test_zdummy(self): + pass + +if __name__ == '__main__': + unittest.main(verbosity=2, exit=False)