Skip to content

Commit 4081c08

Browse files
key262yekyouknowone
authored andcommitted
add cpython_only tag for tests required _testlimitedcapi
1 parent 70c36a4 commit 4081c08

1 file changed

Lines changed: 19 additions & 2 deletions

File tree

‎Lib/test/test_class.py‎

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -445,6 +445,7 @@ def __delattr__(self, *args):
445445
del testme.cardinal
446446
self.assertCallStack([('__delattr__', (testme, "cardinal"))])
447447

448+
@cpython_only
448449
def testHasAttrString(self):
449450
import sys
450451
from test.support import import_helper
@@ -846,8 +847,10 @@ def __init__(self, obj):
846847
Type(i)
847848
self.assertEqual(calls, 100)
848849

849-
850-
from _testinternalcapi import has_inline_values
850+
try:
851+
from _testinternalcapi import has_inline_values
852+
except ImportError:
853+
has_inline_values = None
851854

852855
Py_TPFLAGS_MANAGED_DICT = (1 << 2)
853856

@@ -869,20 +872,27 @@ class TestInlineValues(unittest.TestCase):
869872
def test_flags(self):
870873
self.assertEqual(Plain.__flags__ & Py_TPFLAGS_MANAGED_DICT, Py_TPFLAGS_MANAGED_DICT)
871874
self.assertEqual(WithAttrs.__flags__ & Py_TPFLAGS_MANAGED_DICT, Py_TPFLAGS_MANAGED_DICT)
875+
876+
@cpython_only
872877
def test_has_inline_values(self):
873878
c = Plain()
874879
self.assertTrue(has_inline_values(c))
875880
del c.__dict__
876881
self.assertFalse(has_inline_values(c))
877882

883+
@cpython_only
878884
def test_instances(self):
879885
self.assertTrue(has_inline_values(Plain()))
880886
self.assertTrue(has_inline_values(WithAttrs()))
887+
888+
@cpython_only
881889
def test_inspect_dict(self):
882890
for cls in (Plain, WithAttrs):
883891
c = cls()
884892
c.__dict__
885893
self.assertTrue(has_inline_values(c))
894+
895+
@cpython_only
886896
def test_update_dict(self):
887897
d = { "e": 5, "f": 6 }
888898
for cls in (Plain, WithAttrs):
@@ -898,6 +908,8 @@ def set_100(obj):
898908
def check_100(self, obj):
899909
for i in range(100):
900910
self.assertEqual(getattr(obj, f"a{i}"), i)
911+
912+
@cpython_only
901913
def test_many_attributes(self):
902914
class C: pass
903915
c = C()
@@ -907,6 +919,8 @@ class C: pass
907919
self.check_100(c)
908920
c = C()
909921
self.assertTrue(has_inline_values(c))
922+
923+
@cpython_only
910924
def test_many_attributes_with_dict(self):
911925
class C: pass
912926
c = C()
@@ -972,6 +986,8 @@ class C:
972986
# destructor shouldn't be able to see inconsistent state
973987
C.a = X()
974988
C.a = X()
989+
990+
@cpython_only
975991
def test_detach_materialized_dict_no_memory(self):
976992
# Skip test if _testcapi is not available:
977993
import_helper.import_module('_testcapi')
@@ -1001,5 +1017,6 @@ def __init__(self):
10011017
self.assertEqual(rc, 0)
10021018
self.assertFalse(out, msg=out.decode('utf-8'))
10031019
self.assertFalse(err, msg=err.decode('utf-8'))
1020+
10041021
if __name__ == '__main__':
10051022
unittest.main()

0 commit comments

Comments
 (0)