From: Ɓukasz Langa Date: Tue, 23 Apr 2013 23:49:52 +0000 (+0200) Subject: clean the environment from pre-existing PYTHONWARNINGS for test_warnings X-Git-Tag: v3.3.2~61 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=6ae466732c6a5cd988d02110ab0538c7752a3253;p=thirdparty%2FPython%2Fcpython.git clean the environment from pre-existing PYTHONWARNINGS for test_warnings --- diff --git a/Lib/unittest/test/test_runner.py b/Lib/unittest/test/test_runner.py index aed1e76940a0..e22e6bc279ec 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)