33import pytest
44from pytest import approx # noqa: PT013
55
6- import env # noqa: F401
6+ import env
77from pybind11_tests import ConstructorStats
88from 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" )
111110def 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
0 commit comments