Skip to content

Commit 75e48c5

Browse files
authored
Skip transient tests on GraalPy (#5422)
1 parent f7e14e9 commit 75e48c5

File tree

7 files changed

+24
-2
lines changed

7 files changed

+24
-2
lines changed

tests/test_call_policies.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@ def __init__(self):
190190
)
191191

192192

193+
@pytest.mark.skipif("env.GRAALPY", reason="Cannot reliably trigger GC")
193194
def test_return_none(capture):
194195
n_inst = ConstructorStats.detail_reg_inst()
195196
with capture:
@@ -217,6 +218,7 @@ def test_return_none(capture):
217218
assert capture == "Releasing parent."
218219

219220

221+
@pytest.mark.skipif("env.GRAALPY", reason="Cannot reliably trigger GC")
220222
def test_keep_alive_constructor(capture):
221223
n_inst = ConstructorStats.detail_reg_inst()
222224

tests/test_class.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ def test_instance(msg):
2727

2828
instance = m.NoConstructor.new_instance()
2929

30+
if env.GRAALPY:
31+
pytest.skip("ConstructorStats is incompatible with GraalPy.")
32+
3033
cstats = ConstructorStats.get(m.NoConstructor)
3134
assert cstats.alive() == 1
3235
del instance
@@ -35,6 +38,10 @@ def test_instance(msg):
3538

3639
def test_instance_new():
3740
instance = m.NoConstructorNew() # .__new__(m.NoConstructor.__class__)
41+
42+
if env.GRAALPY:
43+
pytest.skip("ConstructorStats is incompatible with GraalPy.")
44+
3845
cstats = ConstructorStats.get(m.NoConstructorNew)
3946
assert cstats.alive() == 1
4047
del instance

tests/test_copy_move.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import pytest
44

5+
import env # noqa: F401
56
from pybind11_tests import copy_move_policies as m
67

78

@@ -17,6 +18,7 @@ def test_lacking_move_ctor():
1718
assert "is neither movable nor copyable!" in str(excinfo.value)
1819

1920

21+
@pytest.mark.skipif("env.GRAALPY", reason="Cannot reliably trigger GC")
2022
def test_move_and_copy_casts():
2123
"""Cast some values in C++ via custom type casters and count the number of moves/copies."""
2224

@@ -44,6 +46,7 @@ def test_move_and_copy_casts():
4446
assert c_m.alive() + c_mc.alive() + c_c.alive() == 0
4547

4648

49+
@pytest.mark.skipif("env.GRAALPY", reason="Cannot reliably trigger GC")
4750
def test_move_and_copy_loads():
4851
"""Call some functions that load arguments via custom type casters and count the number of
4952
moves/copies."""
@@ -77,6 +80,7 @@ def test_move_and_copy_loads():
7780

7881

7982
@pytest.mark.skipif(not m.has_optional, reason="no <optional>")
83+
@pytest.mark.skipif("env.GRAALPY", reason="Cannot reliably trigger GC")
8084
def test_move_and_copy_load_optional():
8185
"""Tests move/copy loads of std::optional arguments"""
8286

tests/test_custom_type_casters.py

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

33
import pytest
44

5+
import env # noqa: F401
56
from pybind11_tests import custom_type_casters as m
67

78

@@ -94,6 +95,7 @@ def test_noconvert_args(msg):
9495
)
9596

9697

98+
@pytest.mark.skipif("env.GRAALPY", reason="Cannot reliably trigger GC")
9799
def test_custom_caster_destruction():
98100
"""Tests that returning a pointer to a type that gets converted with a custom type caster gets
99101
destroyed when the function has py::return_value_policy::take_ownership policy applied.

tests/test_eigen_matrix.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,7 @@ def test_eigen_return_references():
395395
np.testing.assert_array_equal(a_copy5, c5want)
396396

397397

398+
@pytest.mark.skipif("env.GRAALPY", reason="Cannot reliably trigger GC")
398399
def assert_keeps_alive(cl, method, *args):
399400
cstats = ConstructorStats.get(cl)
400401
start_with = cstats.alive()

tests/test_opaque_types.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import pytest
44

5+
import env
56
from pybind11_tests import ConstructorStats, UserType
67
from pybind11_tests import opaque_types as m
78

@@ -30,7 +31,9 @@ def test_pointers(msg):
3031
living_before = ConstructorStats.get(UserType).alive()
3132
assert m.get_void_ptr_value(m.return_void_ptr()) == 0x1234
3233
assert m.get_void_ptr_value(UserType()) # Should also work for other C++ types
33-
assert ConstructorStats.get(UserType).alive() == living_before
34+
35+
if not env.GRAALPY:
36+
assert ConstructorStats.get(UserType).alive() == living_before
3437

3538
with pytest.raises(TypeError) as excinfo:
3639
m.get_void_ptr_value([1, 2, 3]) # This should not work

tests/test_operator_overloading.py

Lines changed: 4 additions & 1 deletion
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 operators as m
88

@@ -51,6 +51,9 @@ def test_operator_overloading():
5151
v2 /= v1
5252
assert str(v2) == "[2.000000, 8.000000]"
5353

54+
if env.GRAALPY:
55+
pytest.skip("ConstructorStats is incompatible with GraalPy.")
56+
5457
cstats = ConstructorStats.get(m.Vector2)
5558
assert cstats.alive() == 3
5659
del v1

0 commit comments

Comments
 (0)