]> granicus.if.org Git - python/commitdiff
clean the environment from pre-existing PYTHONWARNINGS for test_warnings
authorŁukasz Langa <lukasz@langa.pl>
Tue, 23 Apr 2013 23:49:52 +0000 (01:49 +0200)
committerŁukasz Langa <lukasz@langa.pl>
Tue, 23 Apr 2013 23:49:52 +0000 (01:49 +0200)
Lib/unittest/test/test_runner.py

index aed1e76940a0c934b9b2b8d42ea0e4fa4b96d2b4..e22e6bc279ec23727ed2a84018938233a76e842d 100644 (file)
@@ -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)