diff options
| author | Benjamin Peterson <benjamin@python.org> | 2010-10-17 01:36:15 (GMT) | 
|---|---|---|
| committer | Benjamin Peterson <benjamin@python.org> | 2010-10-17 01:36:15 (GMT) | 
| commit | 6913cb0373e11ac372f6eea563de9e667313c39b (patch) | |
| tree | 22c6c5496dad0c1be19f6d17c9865fb20da09ce2 /Lib/test/test_sys_setprofile.py | |
| parent | 6e982d457adfc79307cceae427d8bb0575a3b0ce (diff) | |
| download | cpython-6913cb0373e11ac372f6eea563de9e667313c39b.zip cpython-6913cb0373e11ac372f6eea563de9e667313c39b.tar.gz cpython-6913cb0373e11ac372f6eea563de9e667313c39b.tar.bz2 | |
Merged revisions 85589-85591 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k
........
  r85589 | benjamin.peterson | 2010-10-16 20:25:19 -0500 (Sat, 16 Oct 2010) | 1 line
  remove rather pointless test
........
  r85590 | benjamin.peterson | 2010-10-16 20:29:11 -0500 (Sat, 16 Oct 2010) | 1 line
  disable the garbage collector while collecting traces, so that __del__s don't get caught
........
  r85591 | benjamin.peterson | 2010-10-16 20:30:26 -0500 (Sat, 16 Oct 2010) | 1 line
  use assertion methods
........
Diffstat (limited to 'Lib/test/test_sys_setprofile.py')
| -rw-r--r-- | Lib/test/test_sys_setprofile.py | 27 | 
1 files changed, 14 insertions, 13 deletions
| diff --git a/Lib/test/test_sys_setprofile.py b/Lib/test/test_sys_setprofile.py index 4083d11..e82559f 100644 --- a/Lib/test/test_sys_setprofile.py +++ b/Lib/test/test_sys_setprofile.py @@ -1,3 +1,4 @@ +import gc  import pprint  import sys  import unittest @@ -12,14 +13,14 @@ class TestGetProfile(unittest.TestCase):          sys.setprofile(None)      def test_empty(self): -        assert sys.getprofile() is None +        self.assertIsNone(sys.getprofile())      def test_setget(self):          def fn(*args):              pass          sys.setprofile(fn) -        assert sys.getprofile() == fn +        self.assertIs(sys.getprofile(), fn)  class HookWatcher:      def __init__(self): @@ -352,19 +353,19 @@ protect_ident = ident(protect)  def capture_events(callable, p=None): -    try: -        sys.setprofile() -    except TypeError: -        pass -    else: -        raise test_support.TestFailed( -            'sys.setprofile() did not raise TypeError') -      if p is None:          p = HookWatcher() -    sys.setprofile(p.callback) -    protect(callable, p) -    sys.setprofile(None) +    # Disable the garbage collector. This prevents __del__s from showing up in +    # traces. +    old_gc = gc.isenabled() +    gc.disable() +    try: +        sys.setprofile(p.callback) +        protect(callable, p) +        sys.setprofile(None) +    finally: +        if old_gc: +            gc.enable()      return p.get_events()[1:-1] | 
