diff options
author | Łukasz Langa <lukasz@langa.pl> | 2013-04-23 23:49:52 (GMT) |
---|---|---|
committer | Łukasz Langa <lukasz@langa.pl> | 2013-04-23 23:49:52 (GMT) |
commit | 6ae466732c6a5cd988d02110ab0538c7752a3253 (patch) | |
tree | 353a0a77611655a4ff80af8242701fc50f208db0 | |
parent | 20ea96f29a8f232513ff4c7d0c16aee895176676 (diff) | |
download | cpython-6ae466732c6a5cd988d02110ab0538c7752a3253.zip cpython-6ae466732c6a5cd988d02110ab0538c7752a3253.tar.gz cpython-6ae466732c6a5cd988d02110ab0538c7752a3253.tar.bz2 |
clean the environment from pre-existing PYTHONWARNINGS for test_warnings
-rw-r--r-- | Lib/unittest/test/test_runner.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/Lib/unittest/test/test_runner.py b/Lib/unittest/test/test_runner.py index aed1e76..e22e6bc 100644 --- a/Lib/unittest/test/test_runner.py +++ b/Lib/unittest/test/test_runner.py @@ -139,6 +139,18 @@ class TestCleanUp(unittest.TestCase): class Test_TextTestRunner(unittest.TestCase): """Tests for TextTestRunner.""" + def setUp(self): + # clean the environment from pre-existing PYTHONWARNINGS to make + # test_warnings results consistent + self.pythonwarnings = os.environ.get('PYTHONWARNINGS') + if self.pythonwarnings: + del os.environ['PYTHONWARNINGS'] + + def tearDown(self): + # bring back pre-existing PYTHONWARNINGS if present + if self.pythonwarnings: + os.environ['PYTHONWARNINGS'] = self.pythonwarnings + def test_init(self): runner = unittest.TextTestRunner() self.assertFalse(runner.failfast) |