Skip to content

Commit ad4203f

Browse files
committed
test: disable Python devmode in pytest
1 parent 2ce1f8a commit ad4203f

File tree

3 files changed

+4
-21
lines changed

3 files changed

+4
-21
lines changed

tests/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,7 @@ set(PYBIND11_PYTEST_ARGS
567567
# A single command to compile and run the tests
568568
add_custom_target(
569569
pytest
570-
COMMAND ${PYBIND11_TEST_PREFIX_COMMAND} ${PYTHON_EXECUTABLE} -X dev -X faulthandler -m pytest
570+
COMMAND ${PYBIND11_TEST_PREFIX_COMMAND} ${PYTHON_EXECUTABLE} -m pytest
571571
${PYBIND11_ABS_PYTEST_FILES} ${PYBIND11_PYTEST_ARGS}
572572
DEPENDS ${test_targets}
573573
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"

tests/test_methods_and_attributes.py

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
from __future__ import annotations
22

3-
import gc
43
import sys
54

65
import pytest
@@ -20,12 +19,6 @@
2019
)
2120

2221

23-
def gc_collect(repeat=5):
24-
"""Collect garbage multiple times to ensure that objects are actually deleted."""
25-
for _ in range(repeat):
26-
gc.collect()
27-
28-
2922
def test_self_only_pos_only():
3023
assert (
3124
m.ExampleMandA.__str__.__doc__
@@ -316,7 +309,7 @@ def test_property_rvalue_policy():
316309
sys.version_info == (3, 14, 0, "beta", 1)
317310
or sys.version_info == (3, 14, 0, "beta", 2),
318311
reason="3.14.0b1/2 bug: https://github.com/python/cpython/issues/133912",
319-
strict=False,
312+
strict=True,
320313
)
321314
def test_dynamic_attributes():
322315
instance = m.DynamicClass()
@@ -344,32 +337,24 @@ def test_dynamic_attributes():
344337
cstats = ConstructorStats.get(m.DynamicClass)
345338
assert cstats.alive() == 1
346339
del instance
347-
gc_collect(repeat=10)
348340
assert cstats.alive() == 0
349341

350342
# Derived classes should work as well
351343
class PythonDerivedDynamicClass(m.DynamicClass):
352344
pass
353345

354-
for cls in (m.CppDerivedDynamicClass, PythonDerivedDynamicClass):
346+
for cls in m.CppDerivedDynamicClass, PythonDerivedDynamicClass:
355347
derived = cls()
356348
derived.foobar = 100
357349
assert derived.foobar == 100
358350

359351
assert cstats.alive() == 1
360352
del derived
361-
gc_collect(repeat=10)
362353
assert cstats.alive() == 0
363354

364355

365356
# https://foss.heptapod.net/pypy/pypy/-/issues/2447
366357
@pytest.mark.xfail("env.PYPY")
367-
@pytest.mark.xfail(
368-
sys.version_info == (3, 14, 0, "beta", 1)
369-
or sys.version_info == (3, 14, 0, "beta", 2),
370-
reason="3.14.0b1/2 bug: https://github.com/python/cpython/issues/133912",
371-
strict=False,
372-
)
373358
@pytest.mark.skipif("env.GRAALPY", reason="Cannot reliably trigger GC")
374359
def test_cyclic_gc():
375360
# One object references itself
@@ -379,7 +364,6 @@ def test_cyclic_gc():
379364
cstats = ConstructorStats.get(m.DynamicClass)
380365
assert cstats.alive() == 1
381366
del instance
382-
gc_collect(repeat=10)
383367
assert cstats.alive() == 0
384368

385369
# Two object reference each other
@@ -390,7 +374,6 @@ def test_cyclic_gc():
390374

391375
assert cstats.alive() == 2
392376
del i1, i2
393-
gc_collect(repeat=10)
394377
assert cstats.alive() == 0
395378

396379

tests/test_pickling.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def test_roundtrip(cls_name):
7272
sys.version_info == (3, 14, 0, "beta", 1)
7373
or sys.version_info == (3, 14, 0, "beta", 2),
7474
reason="3.14.0b1/2 bug: https://github.com/python/cpython/issues/133912",
75-
strict=False,
75+
strict=True,
7676
),
7777
),
7878
"PickleableWithDictNew",

0 commit comments

Comments
 (0)