Skip to content

Commit 6af5fa3

Browse files
committed
Fix test_warnings.test_improper_option()
test_warnings: only run test_improper_option() and test_warnings_bootstrap() once. The unit test doesn't depend on self.module.
1 parent 237f80c commit 6af5fa3

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

Lib/test/test_warnings/__init__.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -534,6 +534,14 @@ def test_improper_input(self):
534534
self.module._setoption('error::Warning::0')
535535
self.assertRaises(UserWarning, self.module.warn, 'convert to error')
536536

537+
538+
class CWCmdLineTests(WCmdLineTests, unittest.TestCase):
539+
module = c_warnings
540+
541+
542+
class PyWCmdLineTests(WCmdLineTests, unittest.TestCase):
543+
module = py_warnings
544+
537545
def test_improper_option(self):
538546
# Same as above, but check that the message is printed out when
539547
# the interpreter is executed. This also checks that options are
@@ -550,12 +558,6 @@ def test_warnings_bootstrap(self):
550558
self.assertFalse(out.strip())
551559
self.assertNotIn(b'RuntimeWarning', err)
552560

553-
class CWCmdLineTests(WCmdLineTests, unittest.TestCase):
554-
module = c_warnings
555-
556-
class PyWCmdLineTests(WCmdLineTests, unittest.TestCase):
557-
module = py_warnings
558-
559561

560562
class _WarningsTests(BaseTest, unittest.TestCase):
561563

@@ -931,6 +933,7 @@ def test_issue_8766(self):
931933
# Use -W to load warnings module at startup
932934
assert_python_ok('-c', 'pass', '-W', 'always', PYTHONPATH=cwd)
933935

936+
934937
class FinalizationTest(unittest.TestCase):
935938
def test_finalization(self):
936939
# Issue #19421: warnings.warn() should not crash

0 commit comments

Comments
 (0)