[Python-checkins] r62485 - python/trunk/Lib/test/test_trace.py
amaury.forgeotdarc
python-checkins at python.org
Thu Apr 24 22:10:44 CEST 2008
Author: amaury.forgeotdarc
Date: Thu Apr 24 22:10:26 2008
New Revision: 62485
Log:
Disable gc when running test_trace, or we may record the __del__ of collected objects.
See http://mail.python.org/pipermail/python-checkins/2008-April/068633.html
the extra events perfectly match several calls to socket._fileobject.__del__()
Modified:
python/trunk/Lib/test/test_trace.py
Modified: python/trunk/Lib/test/test_trace.py
==============================================================================
--- python/trunk/Lib/test/test_trace.py (original)
+++ python/trunk/Lib/test/test_trace.py Thu Apr 24 22:10:26 2008
@@ -4,6 +4,7 @@
import unittest
import sys
import difflib
+import gc
# A very basic example. If this fails, we're in deep trouble.
def basic():
@@ -244,6 +245,17 @@
return self.trace
class TraceTestCase(unittest.TestCase):
+
+ # Disable gc collection when tracing, otherwise the
+ # deallocators may be traced as well.
+ def setUp(self):
+ self.using_gc = gc.isenabled()
+ gc.disable()
+
+ def tearDown(self):
+ if self.using_gc:
+ gc.enable()
+
def compare_events(self, line_offset, events, expected_events):
events = [(l - line_offset, e) for (l, e) in events]
if events != expected_events:
More information about the Python-checkins
mailing list