diff options
author | ?ukasz Langa <lukasz@langa.pl> | 2013-04-24 01:49:52 +0200 |
---|---|---|
committer | ?ukasz Langa <lukasz@langa.pl> | 2013-04-24 01:49:52 +0200 |
commit | 9dfbd23c6fa5737956b5a4cf1241e9b51cac1dbc (patch) | |
tree | b2518207685cf702590783e09144eb5502d543af | |
parent | b5cba5cd7b6e7d691ec9d32b5352078578e91c47 (diff) | |
download | cpython-9dfbd23c6fa5737956b5a4cf1241e9b51cac1dbc.tar.gz |
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 aed1e76940..e22e6bc279 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) |