Skip to content

Commit 6c5d25a

Browse files
authored
test: run pytest under Python devmode (#5715)
* test: run pytest under Python devmode * test: skip segfault bug with 3.14.0b1/2 * test: skip segfault bug with 3.14.0b1/2 * test: unset CMAKE_BUILD_PARALLEL_LEVEL
1 parent 5d32ed7 commit 6c5d25a

File tree

5 files changed

+28
-11
lines changed

5 files changed

+28
-11
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ concurrency:
1616
cancel-in-progress: true
1717

1818
env:
19+
PYTHONDEVMODE: 1
1920
PIP_BREAK_SYSTEM_PACKAGES: 1
2021
PIP_ONLY_BINARY: numpy
2122
FORCE_COLOR: 3

.github/workflows/reusable-standard.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,16 @@ on:
1414
required: true
1515
type: string
1616

17+
env:
18+
PYTHONDEVMODE: 1
19+
PIP_BREAK_SYSTEM_PACKAGES: 1
20+
PIP_ONLY_BINARY: numpy
21+
FORCE_COLOR: 3
22+
PYTEST_TIMEOUT: 300
23+
# For cmake:
24+
VERBOSE: 1
25+
CMAKE_COLOR_DIAGNOSTICS: 1
26+
1727
jobs:
1828
standard:
1929
name: 🧪

tests/conftest.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,8 @@ def gc_collect():
206206
gc.collect()
207207
gc.collect()
208208
gc.collect()
209+
gc.collect()
210+
gc.collect()
209211

210212

211213
def pytest_configure():

tests/test_methods_and_attributes.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -305,11 +305,9 @@ def test_property_rvalue_policy():
305305

306306
# https://foss.heptapod.net/pypy/pypy/-/issues/2447
307307
@pytest.mark.xfail("env.PYPY")
308-
@pytest.mark.xfail(
309-
sys.version_info == (3, 14, 0, "beta", 1)
310-
or sys.version_info == (3, 14, 0, "beta", 2),
311-
reason="3.14.0b1/2 bug: https://github.com/python/cpython/issues/133912",
312-
strict=True,
308+
@pytest.mark.skipif(
309+
sys.version_info in ((3, 14, 0, "beta", 1), (3, 14, 0, "beta", 2)),
310+
reason="3.14.0b1/2 managed dict bug: https://github.com/python/cpython/issues/133912",
313311
)
314312
def test_dynamic_attributes():
315313
instance = m.DynamicClass()
@@ -337,25 +335,31 @@ def test_dynamic_attributes():
337335
cstats = ConstructorStats.get(m.DynamicClass)
338336
assert cstats.alive() == 1
339337
del instance
338+
pytest.gc_collect()
340339
assert cstats.alive() == 0
341340

342341
# Derived classes should work as well
343342
class PythonDerivedDynamicClass(m.DynamicClass):
344343
pass
345344

346-
for cls in m.CppDerivedDynamicClass, PythonDerivedDynamicClass:
345+
for cls in (m.CppDerivedDynamicClass, PythonDerivedDynamicClass):
347346
derived = cls()
348347
derived.foobar = 100
349348
assert derived.foobar == 100
350349

351350
assert cstats.alive() == 1
352351
del derived
352+
pytest.gc_collect()
353353
assert cstats.alive() == 0
354354

355355

356356
# https://foss.heptapod.net/pypy/pypy/-/issues/2447
357357
@pytest.mark.xfail("env.PYPY")
358358
@pytest.mark.skipif("env.GRAALPY", reason="Cannot reliably trigger GC")
359+
@pytest.mark.skipif(
360+
sys.version_info in ((3, 14, 0, "beta", 1), (3, 14, 0, "beta", 2)),
361+
reason="3.14.0b1/2 managed dict bug: https://github.com/python/cpython/issues/133912",
362+
)
359363
def test_cyclic_gc():
360364
# One object references itself
361365
instance = m.DynamicClass()
@@ -364,6 +368,7 @@ def test_cyclic_gc():
364368
cstats = ConstructorStats.get(m.DynamicClass)
365369
assert cstats.alive() == 1
366370
del instance
371+
pytest.gc_collect()
367372
assert cstats.alive() == 0
368373

369374
# Two object reference each other
@@ -374,6 +379,7 @@ def test_cyclic_gc():
374379

375380
assert cstats.alive() == 2
376381
del i1, i2
382+
pytest.gc_collect()
377383
assert cstats.alive() == 0
378384

379385

tests/test_pickling.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,9 @@ def test_roundtrip(cls_name):
6868
[
6969
pytest.param(
7070
"PickleableWithDict",
71-
marks=pytest.mark.xfail(
72-
sys.version_info == (3, 14, 0, "beta", 1)
73-
or sys.version_info == (3, 14, 0, "beta", 2),
74-
reason="3.14.0b1/2 bug: https://github.com/python/cpython/issues/133912",
75-
strict=True,
71+
marks=pytest.mark.skipif(
72+
sys.version_info in ((3, 14, 0, "beta", 1), (3, 14, 0, "beta", 2)),
73+
reason="3.14.0b1/2 managed dict bug: https://github.com/python/cpython/issues/133912",
7674
),
7775
),
7876
"PickleableWithDictNew",

0 commit comments

Comments
 (0)