Skip to content

Commit ebd7898

Browse files
committed
Try to narrow down skipped tests
1 parent eb409c5 commit ebd7898

File tree

7 files changed

+57
-35
lines changed

7 files changed

+57
-35
lines changed

tests/test_buffers.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ def test_format_descriptor_format_buffer_info_equiv(cpp_name, np_dtype):
7070
assert not np_array_is_matching
7171

7272

73-
@pytest.mark.skipif("env.GRAALPY", reason="Cannot reliably trigger GC")
7473
def test_from_python():
7574
with pytest.raises(RuntimeError) as excinfo:
7675
m.Matrix(np.array([1, 2, 3])) # trying to assign a 1D array
@@ -83,6 +82,8 @@ def test_from_python():
8382
for j in range(m4.cols()):
8483
assert m3[i, j] == m4[i, j]
8584

85+
if env.GRAALPY:
86+
pytest.skip("ConstructorStats is incompatible with GraalPy.")
8687
cstats = ConstructorStats.get(m.Matrix)
8788
assert cstats.alive() == 1
8889
del m3, m4
@@ -99,7 +100,6 @@ def test_from_python():
99100
@pytest.mark.xfail(
100101
env.PYPY, reason="PyPy 7.3.7 doesn't clear this anymore", strict=False
101102
)
102-
@pytest.mark.skipif("env.GRAALPY", reason="Cannot reliably trigger GC")
103103
def test_to_python():
104104
mat = m.Matrix(5, 4)
105105
assert memoryview(mat).shape == (5, 4)
@@ -120,6 +120,8 @@ def test_to_python():
120120
mat2[2, 3] = 5
121121
assert mat2[2, 3] == 5
122122

123+
if env.GRAALPY:
124+
pytest.skip("ConstructorStats is incompatible with GraalPy.")
123125
cstats = ConstructorStats.get(m.Matrix)
124126
assert cstats.alive() == 1
125127
del mat

tests/test_cpp_conduit.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import home_planet_very_lonely_traveler
88
import pytest
99

10-
import env # noqa: F401
10+
import env
1111
from pybind11_tests import cpp_conduit as home_planet
1212

1313

@@ -21,15 +21,17 @@ def test_premium_traveler_getattr_actually_exists():
2121
assert t_h.secret_name == "PremiumTraveler GetAttr: secret_name points: 7"
2222

2323

24-
@pytest.mark.xfail("env.GRAALPY", reason="TODO should get fixed on GraalPy side")
2524
def test_call_cpp_conduit_success():
2625
t_h = home_planet.Traveler("home")
2726
cap = t_h._pybind11_conduit_v1_(
2827
home_planet.PYBIND11_PLATFORM_ABI_ID,
2928
home_planet.cpp_type_info_capsule_Traveler,
3029
b"raw_pointer_ephemeral",
3130
)
32-
assert cap.__class__.__name__ == "PyCapsule"
31+
assert cap.__class__.__name__ == "PyCapsule" or (
32+
# Note: this will become unnecessary in the next GraalPy release
33+
env.GRAALPY and cap.__class__.__name__ == "capsule"
34+
)
3335

3436

3537
def test_call_cpp_conduit_platform_abi_id_mismatch():

tests/test_methods_and_attributes.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
import pytest
66

7-
import env # noqa: F401
7+
import env
88
from pybind11_tests import ConstructorStats
99
from pybind11_tests import methods_and_attributes as m
1010

@@ -19,7 +19,6 @@
1919
)
2020

2121

22-
@pytest.mark.skipif("env.GRAALPY", reason="Cannot reliably trigger GC")
2322
def test_methods_and_attributes():
2423
instance1 = m.ExampleMandA()
2524
instance2 = m.ExampleMandA(32)
@@ -69,6 +68,9 @@ def test_methods_and_attributes():
6968
instance1.value = 100
7069
assert str(instance1) == "ExampleMandA[value=100]"
7170

71+
if env.GRAALPY:
72+
pytest.skip("ConstructorStats is incompatible with GraalPy.")
73+
7274
cstats = ConstructorStats.get(m.ExampleMandA)
7375
assert cstats.alive() == 2
7476
del instance1, instance2
@@ -296,7 +298,6 @@ def test_property_rvalue_policy():
296298

297299
# https://foss.heptapod.net/pypy/pypy/-/issues/2447
298300
@pytest.mark.xfail("env.PYPY")
299-
@pytest.mark.skipif("env.GRAALPY", reason="Cannot reliably trigger GC")
300301
def test_dynamic_attributes():
301302
instance = m.DynamicClass()
302303
assert not hasattr(instance, "foo")
@@ -318,6 +319,8 @@ def test_dynamic_attributes():
318319
instance.__dict__ = []
319320
assert str(excinfo.value) == "__dict__ must be set to a dictionary, not a 'list'"
320321

322+
if env.GRAALPY:
323+
pytest.skip("ConstructorStats is incompatible with GraalPy.")
321324
cstats = ConstructorStats.get(m.DynamicClass)
322325
assert cstats.alive() == 1
323326
del instance

tests/test_modules.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ def test_nested_modules():
2525
assert ms.submodule_func() == "submodule_func()"
2626

2727

28-
@pytest.mark.skipif("env.GRAALPY", reason="Cannot reliably trigger GC")
2928
def test_reference_internal():
3029
b = ms.B()
3130
assert str(b.get_a1()) == "A[1]"
@@ -40,6 +39,9 @@ def test_reference_internal():
4039
assert str(b.get_a2()) == "A[43]"
4140
assert str(b.a2) == "A[43]"
4241

42+
if env.GRAALPY:
43+
pytest.skip("ConstructorStats is incompatible with GraalPy.")
44+
4345
astats, bstats = ConstructorStats.get(ms.A), ConstructorStats.get(ms.B)
4446
assert astats.alive() == 2
4547
assert bstats.alive() == 1

tests/test_multiple_inheritance.py

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import pytest
44

5-
import env # noqa: F401
5+
import env
66
from pybind11_tests import ConstructorStats
77
from pybind11_tests import multiple_inheritance as m
88

@@ -272,16 +272,16 @@ def test_mi_dynamic_attributes():
272272
assert d.dynamic == 1
273273

274274

275-
@pytest.mark.skipif("env.GRAALPY", reason="Cannot reliably trigger GC")
276275
def test_mi_unaligned_base():
277276
"""Returning an offset (non-first MI) base class pointer should recognize the instance"""
278277

279278
n_inst = ConstructorStats.detail_reg_inst()
280279

281280
c = m.I801C()
282281
d = m.I801D()
283-
# + 4 below because we have the two instances, and each instance has offset base I801B2
284-
assert ConstructorStats.detail_reg_inst() == n_inst + 4
282+
if not env.GRAALPY:
283+
# + 4 below because we have the two instances, and each instance has offset base I801B2
284+
assert ConstructorStats.detail_reg_inst() == n_inst + 4
285285
b1c = m.i801b1_c(c)
286286
assert b1c is c
287287
b2c = m.i801b2_c(c)
@@ -291,14 +291,16 @@ def test_mi_unaligned_base():
291291
b2d = m.i801b2_d(d)
292292
assert b2d is d
293293

294+
if env.GRAALPY:
295+
pytest.skip("ConstructorStats is incompatible with GraalPy.")
296+
294297
assert ConstructorStats.detail_reg_inst() == n_inst + 4 # no extra instances
295298
del c, b1c, b2c
296299
assert ConstructorStats.detail_reg_inst() == n_inst + 2
297300
del d, b1d, b2d
298301
assert ConstructorStats.detail_reg_inst() == n_inst
299302

300303

301-
@pytest.mark.skipif("env.GRAALPY", reason="Cannot reliably trigger GC")
302304
def test_mi_base_return():
303305
"""Tests returning an offset (non-first MI) base class pointer to a derived instance"""
304306

@@ -314,7 +316,8 @@ def test_mi_base_return():
314316
assert d1.a == 1
315317
assert d1.b == 2
316318

317-
assert ConstructorStats.detail_reg_inst() == n_inst + 4
319+
if not env.GRAALPY:
320+
assert ConstructorStats.detail_reg_inst() == n_inst + 4
318321

319322
c2 = m.i801c_b2()
320323
assert type(c2) is m.I801C
@@ -326,12 +329,13 @@ def test_mi_base_return():
326329
assert d2.a == 1
327330
assert d2.b == 2
328331

329-
assert ConstructorStats.detail_reg_inst() == n_inst + 8
332+
if not env.GRAALPY:
333+
assert ConstructorStats.detail_reg_inst() == n_inst + 8
330334

331-
del c2
332-
assert ConstructorStats.detail_reg_inst() == n_inst + 6
333-
del c1, d1, d2
334-
assert ConstructorStats.detail_reg_inst() == n_inst
335+
del c2
336+
assert ConstructorStats.detail_reg_inst() == n_inst + 6
337+
del c1, d1, d2
338+
assert ConstructorStats.detail_reg_inst() == n_inst
335339

336340
# Returning an unregistered derived type with a registered base; we won't
337341
# pick up the derived type, obviously, but should still work (as an object

tests/test_sequences_and_iterators.py

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import pytest
44
from pytest import approx # noqa: PT013
55

6-
import env # noqa: F401
6+
import env
77
from pybind11_tests import ConstructorStats
88
from pybind11_tests import sequences_and_iterators as m
99

@@ -107,12 +107,12 @@ def test_sliceable():
107107
assert sliceable[50:60:-1] == (50, 60, -1)
108108

109109

110-
@pytest.mark.skipif("env.GRAALPY", reason="Cannot reliably trigger GC")
111110
def test_sequence():
112111
cstats = ConstructorStats.get(m.Sequence)
113112

114113
s = m.Sequence(5)
115-
assert cstats.values() == ["of size", "5"]
114+
if not env.GRAALPY:
115+
assert cstats.values() == ["of size", "5"]
116116

117117
assert "Sequence" in repr(s)
118118
assert len(s) == 5
@@ -125,27 +125,34 @@ def test_sequence():
125125
assert s[3] == approx(56.78, rel=1e-05)
126126

127127
rev = reversed(s)
128-
assert cstats.values() == ["of size", "5"]
128+
if not env.GRAALPY:
129+
assert cstats.values() == ["of size", "5"]
129130

130131
rev2 = s[::-1]
131-
assert cstats.values() == ["of size", "5"]
132+
if not env.GRAALPY:
133+
assert cstats.values() == ["of size", "5"]
132134

133135
it = iter(m.Sequence(0))
134136
for _ in range(3): # __next__ must continue to raise StopIteration
135137
with pytest.raises(StopIteration):
136138
next(it)
137-
assert cstats.values() == ["of size", "0"]
139+
if not env.GRAALPY:
140+
assert cstats.values() == ["of size", "0"]
138141

139142
expected = [0, 56.78, 0, 0, 12.34]
140143
assert rev == approx(expected, rel=1e-05)
141144
assert rev2 == approx(expected, rel=1e-05)
142145
assert rev == rev2
143146

144147
rev[0::2] = m.Sequence([2.0, 2.0, 2.0])
145-
assert cstats.values() == ["of size", "3", "from std::vector"]
148+
if not env.GRAALPY:
149+
assert cstats.values() == ["of size", "3", "from std::vector"]
146150

147151
assert rev == approx([2, 56.78, 2, 0, 2], rel=1e-05)
148152

153+
if env.GRAALPY:
154+
pytest.skip("ConstructorStats is incompatible with GraalPy.")
155+
149156
assert cstats.alive() == 4
150157
del it
151158
assert cstats.alive() == 3

tests/test_virtual_functions.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -82,14 +82,16 @@ def get_string2(self):
8282
"""
8383
)
8484

85-
if not env.GRAALPY:
86-
cstats = ConstructorStats.get(m.ExampleVirt)
87-
assert cstats.alive() == 3
88-
del ex12, ex12p, ex12p2
89-
assert cstats.alive() == 0
90-
assert cstats.values() == ["10", "11", "17"]
91-
assert cstats.copy_constructions == 0
92-
assert cstats.move_constructions >= 0
85+
if env.GRAALPY:
86+
pytest.skip("ConstructorStats is incompatible with GraalPy.")
87+
88+
cstats = ConstructorStats.get(m.ExampleVirt)
89+
assert cstats.alive() == 3
90+
del ex12, ex12p, ex12p2
91+
assert cstats.alive() == 0
92+
assert cstats.values() == ["10", "11", "17"]
93+
assert cstats.copy_constructions == 0
94+
assert cstats.move_constructions >= 0
9395

9496

9597
@pytest.mark.skipif("env.GRAALPY", reason="Cannot reliably trigger GC")

0 commit comments

Comments
 (0)