[Python-checkins] r67040 - python/trunk/Lib/test/test_descr.py

armin.rigo python-checkins at python.org
Tue Oct 28 18:01:21 CET 2008


Author: armin.rigo
Date: Tue Oct 28 18:01:21 2008
New Revision: 67040

Log:
Fix one of the tests: it relied on being present in an "output test" in
order to actually test what it was supposed to test, i.e. that the code
in the __del__ method did not crash.  Use instead the new helper
test_support.captured_output().


Modified:
   python/trunk/Lib/test/test_descr.py

Modified: python/trunk/Lib/test/test_descr.py
==============================================================================
--- python/trunk/Lib/test/test_descr.py	(original)
+++ python/trunk/Lib/test/test_descr.py	Tue Oct 28 18:01:21 2008
@@ -1136,14 +1136,10 @@
             def __del__(self_):
                 self.assertEqual(self_.a, 1)
                 self.assertEqual(self_.b, 2)
-
-        save_stderr = sys.stderr
-        sys.stderr = sys.stdout
-        h = H()
-        try:
+        with test_support.captured_output('stderr') as s:
+            h = H()
             del h
-        finally:
-            sys.stderr = save_stderr
+        self.assertEqual(s.getvalue(), '')
 
     def test_slots_special(self):
         # Testing __dict__ and __weakref__ in __slots__...


More information about the Python-checkins mailing list