summaryrefslogtreecommitdiff
path: root/Lib/test/test_global.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test/test_global.py')
-rw-r--r--Lib/test/test_global.py14
1 files changed, 8 insertions, 6 deletions
diff --git a/Lib/test/test_global.py b/Lib/test/test_global.py
index 8159602be9..e60f00206b 100644
--- a/Lib/test/test_global.py
+++ b/Lib/test/test_global.py
@@ -1,6 +1,6 @@
"""Verify that warnings are issued for global statements following use."""
-from test.support import run_unittest, check_syntax_error, check_warnings
+from test.support import check_syntax_error, check_warnings
import unittest
import warnings
@@ -52,10 +52,12 @@ x = 2
compile(prog_text_4, "<test string>", "exec")
-def test_main():
- with warnings.catch_warnings():
- warnings.filterwarnings("error", module="<test string>")
- run_unittest(GlobalTests)
+def setUpModule():
+ cm = warnings.catch_warnings()
+ cm.__enter__()
+ unittest.addModuleCleanup(cm.__exit__, None, None, None)
+ warnings.filterwarnings("error", module="<test string>")
+
if __name__ == "__main__":
- test_main()
+ unittest.main()