summaryrefslogtreecommitdiff
path: root/Lib/test/test_gc.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2014-02-07 10:10:55 +0200
committerSerhiy Storchaka <storchaka@gmail.com>2014-02-07 10:10:55 +0200
commitf28ba369dd068a76ff5b7efac58fdcb5c3eaf4dd (patch)
tree541cb209a2be79d6022ce5d47216755e9e9310a4 /Lib/test/test_gc.py
parent622be340fdf4110c77e1f86bd13a01fc30c2bb65 (diff)
parent5cfc79deaeabf4af3c767665098a37da9f375eda (diff)
downloadcpython-git-f28ba369dd068a76ff5b7efac58fdcb5c3eaf4dd.tar.gz
Issue #20532: Tests which use _testcapi now are marked as CPython only.
Diffstat (limited to 'Lib/test/test_gc.py')
-rw-r--r--Lib/test/test_gc.py22
1 files changed, 17 insertions, 5 deletions
diff --git a/Lib/test/test_gc.py b/Lib/test/test_gc.py
index e8f52a508f..7eb104a6b5 100644
--- a/Lib/test/test_gc.py
+++ b/Lib/test/test_gc.py
@@ -1,7 +1,6 @@
-import _testcapi
import unittest
from test.support import (verbose, refcount_test, run_unittest,
- strip_python_stderr)
+ strip_python_stderr, cpython_only)
from test.script_helper import assert_python_ok, make_script, temp_dir
import sys
@@ -14,6 +13,15 @@ try:
except ImportError:
threading = None
+try:
+ from _testcapi import with_tp_del
+except ImportError:
+ def with_tp_del(cls):
+ class C(object):
+ def __new__(cls, *args, **kwargs):
+ raise TypeError('requires _testcapi.with_tp_del')
+ return C
+
### Support code
###############################################################################
@@ -41,7 +49,7 @@ class GC_Detector(object):
# gc collects it.
self.wr = weakref.ref(C1055820(666), it_happened)
-@_testcapi.with_tp_del
+@with_tp_del
class Uncollectable(object):
"""Create a reference cycle with multiple __del__ methods.
@@ -143,10 +151,11 @@ class GCTests(unittest.TestCase):
del a
self.assertNotEqual(gc.collect(), 0)
+ @cpython_only
def test_legacy_finalizer(self):
# A() is uncollectable if it is part of a cycle, make sure it shows up
# in gc.garbage.
- @_testcapi.with_tp_del
+ @with_tp_del
class A:
def __tp_del__(self): pass
class B:
@@ -168,10 +177,11 @@ class GCTests(unittest.TestCase):
self.fail("didn't find obj in garbage (finalizer)")
gc.garbage.remove(obj)
+ @cpython_only
def test_legacy_finalizer_newclass(self):
# A() is uncollectable if it is part of a cycle, make sure it shows up
# in gc.garbage.
- @_testcapi.with_tp_del
+ @with_tp_del
class A(object):
def __tp_del__(self): pass
class B(object):
@@ -570,6 +580,7 @@ class GCTests(unittest.TestCase):
# would be damaged, with an empty __dict__.
self.assertEqual(x, None)
+ @cpython_only
def test_garbage_at_shutdown(self):
import subprocess
code = """if 1:
@@ -764,6 +775,7 @@ class GCCallbackTests(unittest.TestCase):
info = v[2]
self.assertEqual(info["generation"], 2)
+ @cpython_only
def test_collect_garbage(self):
self.preclean()
# Each of these cause four objects to be garbage: Two