~pythonregexp2.7/python/issue2636-22

« back to all changes in this revision

Viewing changes to Lib/test/test_trace.py

  • Committer: amaury.forgeotdarc
  • Date: 2008-04-24 20:10:26 UTC
  • Revision ID: svn-v3-trunk1:6015fed2-1504-0410-9fe1-9d1591cc4771:python%2Ftrunk:62485
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__()

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
import unittest
5
5
import sys
6
6
import difflib
 
7
import gc
7
8
 
8
9
# A very basic example.  If this fails, we're in deep trouble.
9
10
def basic():
244
245
        return self.trace
245
246
 
246
247
class TraceTestCase(unittest.TestCase):
 
248
 
 
249
    # Disable gc collection when tracing, otherwise the
 
250
    # deallocators may be traced as well.
 
251
    def setUp(self):
 
252
        self.using_gc = gc.isenabled()
 
253
        gc.disable()
 
254
 
 
255
    def tearDown(self):
 
256
        if self.using_gc:
 
257
            gc.enable()
 
258
 
247
259
    def compare_events(self, line_offset, events, expected_events):
248
260
        events = [(l - line_offset, e) for (l, e) in events]
249
261
        if events != expected_events: