From 16be1fd8dfd4dd065eac4de9978a286b85176d1b Mon Sep 17 00:00:00 2001 From: Sam Gross Date: Wed, 19 Feb 2025 21:49:22 +0000 Subject: [PATCH] test_c.py cannot import testing.support --- src/c/test_c.py | 10 +++++++--- testing/support.py | 7 ------- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/src/c/test_c.py b/src/c/test_c.py index 32a9d2f5..ad691e4e 100644 --- a/src/c/test_c.py +++ b/src/c/test_c.py @@ -6,7 +6,6 @@ import pytest import sys -import testing.support import typing as t is_musl = False @@ -3407,9 +3406,14 @@ def test_bitfield_as_ppc_gcc(): def buffer_warning(cdata): - testing.support.skip_if_multithreaded() - + import threading import warnings + + # warnings.catch_warnings() is not currently thread-safe, so skip the + # remainder of this test if running with `pytest-run-parallel`. + if threading.current_thread() != threading.main_thread(): + pytest.skip("cannot run in a secondary thread") + buf = buffer(cdata) bytes = len(buf) with warnings.catch_warnings(record=True) as w: diff --git a/testing/support.py b/testing/support.py index 410029b3..063e52cf 100644 --- a/testing/support.py +++ b/testing/support.py @@ -1,5 +1,4 @@ import sys, os -import pytest from cffi._imp_emulation import load_dynamic if sys.version_info < (3,): @@ -98,12 +97,6 @@ def typeof_disabled(*args, **kwds): return module.lib -def skip_if_multithreaded(): - import threading - if threading.current_thread() != threading.main_thread(): - pytest.skip("cannot run in a secondary thread") - - # For testing, we call gcc with "-Werror". This is fragile because newer # versions of gcc are always better at producing warnings, particularly for # auto-generated code. We need here to adapt and silence them as needed.