[Python-checkins] cpython (3.3): clean the environment from pre-existing PYTHONWARNINGS for test_warnings

lukasz.langa python-checkins at python.org
Wed Apr 24 01:52:16 CEST 2013


http://hg.python.org/cpython/rev/601570064725
changeset:   83512:601570064725
branch:      3.3
parent:      83510:9755036c81d0
user:        Łukasz Langa <lukasz at langa.pl>
date:        Wed Apr 24 01:49:52 2013 +0200
summary:
  clean the environment from pre-existing PYTHONWARNINGS for test_warnings

files:
  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
--- a/Lib/unittest/test/test_runner.py
+++ b/Lib/unittest/test/test_runner.py
@@ -139,6 +139,18 @@
 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)

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list