summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorAmaury Forgeot d'Arc <amauryfa@gmail.com>2008-04-24 20:10:26 (GMT)
committerAmaury Forgeot d'Arc <amauryfa@gmail.com>2008-04-24 20:10:26 (GMT)
commit48ebc264f8a92824f3872049a581f0e45d1a5009 (patch)
tree87db92c58b3d5ef5aec16bcff37ff5dd95d133de /Lib/test
parentbf027c48c8547f262f5ef5981c3ae44273ae249d (diff)
downloadcpython-48ebc264f8a92824f3872049a581f0e45d1a5009.zip
cpython-48ebc264f8a92824f3872049a581f0e45d1a5009.tar.gz
cpython-48ebc264f8a92824f3872049a581f0e45d1a5009.tar.bz2
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__()
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_trace.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/Lib/test/test_trace.py b/Lib/test/test_trace.py
index 6ad38d1..b5db9a7 100644
--- a/Lib/test/test_trace.py
+++ b/Lib/test/test_trace.py
@@ -4,6 +4,7 @@ from test import test_support
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 @@ class Tracer:
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: