]> granicus.if.org Git - python/commitdiff
Fix test_warnings.test_improper_option()
authorVictor Stinner <victor.stinner@gmail.com>
Thu, 24 Mar 2016 23:28:56 +0000 (00:28 +0100)
committerVictor Stinner <victor.stinner@gmail.com>
Thu, 24 Mar 2016 23:28:56 +0000 (00:28 +0100)
test_warnings: only run test_improper_option() and test_warnings_bootstrap()
once. The unit test doesn't depend on self.module.

Lib/test/test_warnings/__init__.py

index cea9c574abfabf5f1f89ab704449521e4afae071..eda755dbc2156ec4d521282a03e4e4e214ea9650 100644 (file)
@@ -534,6 +534,14 @@ class WCmdLineTests(BaseTest):
             self.module._setoption('error::Warning::0')
             self.assertRaises(UserWarning, self.module.warn, 'convert to error')
 
+
+class CWCmdLineTests(WCmdLineTests, unittest.TestCase):
+    module = c_warnings
+
+
+class PyWCmdLineTests(WCmdLineTests, unittest.TestCase):
+    module = py_warnings
+
     def test_improper_option(self):
         # Same as above, but check that the message is printed out when
         # the interpreter is executed. This also checks that options are
@@ -550,12 +558,6 @@ class WCmdLineTests(BaseTest):
         self.assertFalse(out.strip())
         self.assertNotIn(b'RuntimeWarning', err)
 
-class CWCmdLineTests(WCmdLineTests, unittest.TestCase):
-    module = c_warnings
-
-class PyWCmdLineTests(WCmdLineTests, unittest.TestCase):
-    module = py_warnings
-
 
 class _WarningsTests(BaseTest, unittest.TestCase):
 
@@ -931,6 +933,7 @@ class BootstrapTest(unittest.TestCase):
             # Use -W to load warnings module at startup
             assert_python_ok('-c', 'pass', '-W', 'always', PYTHONPATH=cwd)
 
+
 class FinalizationTest(unittest.TestCase):
     def test_finalization(self):
         # Issue #19421: warnings.warn() should not crash