mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
Issue #20532: Tests which use _testcapi now are marked as CPython only.
This commit is contained in:
commit
f28ba369dd
29 changed files with 284 additions and 118 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue