]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Fix one of the tests: it relied on being present in an "output test" in
authorArmin Rigo <arigo@tunes.org>
Tue, 28 Oct 2008 17:01:21 +0000 (17:01 +0000)
committerArmin Rigo <arigo@tunes.org>
Tue, 28 Oct 2008 17:01:21 +0000 (17:01 +0000)
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().

Lib/test/test_descr.py

index f170d591a60556c810196519ff4771dd3975bcf3..f74073811fef7a0c4f5dbdf41d1675482dfcb1b3 100644 (file)
@@ -1136,14 +1136,10 @@ order (MRO) for bases """
             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__...