From f946b791460ed17cfd21471ad11d2e50d2adafc7 Mon Sep 17 00:00:00 2001 From: Sergey B Kirpichev Date: Mon, 2 Feb 2026 09:46:28 +0300 Subject: [PATCH 1/6] Alter hypothesis settings in pytest_configure() This permits to prevent loading of the hypothesis plugin, if it's disabled by -p no:hypothesispytest. --- tests/conftest.py | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index d25d6a30..b125f199 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,23 +1,22 @@ -import os -import platform -from datetime import timedelta +def pytest_configure(config): + if "no:hypothesispytest" not in config.getoption("-p"): + import platform -import gmp -from hypothesis import settings + from hypothesis import settings -default = settings.get_profile("default") -settings.register_profile("default", - settings(default, - deadline=timedelta(seconds=300))) -ci = settings.get_profile("ci") -if platform.python_implementation() != "GraalVM": - ci = settings(ci, max_examples=10000) -else: - ci = settings(ci, max_examples=1000) -settings.register_profile("ci", ci) + default = settings.get_profile("default") + settings.register_profile("default", settings(default, deadline=700)) + ci = settings.get_profile("ci") + if platform.python_implementation() != "GraalVM": + ci = settings(ci, max_examples=10000) + else: + ci = settings(ci, max_examples=1000) + settings.register_profile("ci", ci) def pytest_report_header(config): + import gmp + print(f""" Using the ZZ library v{gmp._zz_version} @@ -28,4 +27,6 @@ def pytest_report_header(config): def pytest_sessionstart(session): + import os + os.environ["MPMATH_NOGMPY"] = "Y" From 61e9b7e1903bdd382edb3c5c61e328d208df3845 Mon Sep 17 00:00:00 2001 From: Sergey B Kirpichev Date: Mon, 2 Feb 2026 09:57:38 +0300 Subject: [PATCH 2/6] Reduce number of iterations in test_fac/square_outofmem() --- tests/test_memory.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_memory.py b/tests/test_memory.py index 890affc4..ca0e533a 100644 --- a/tests/test_memory.py +++ b/tests/test_memory.py @@ -21,7 +21,7 @@ def test_fac_outofmem(): - for _ in range(100): + for _ in range(20): x = random.randint(12811, 24984) soft, hard = resource.getrlimit(resource.RLIMIT_AS) resource.setrlimit(resource.RLIMIT_AS, (VMEM_LIMIT, hard)) @@ -38,7 +38,7 @@ def test_fac_outofmem(): def test_square_outofmem(): - for _ in range(100): + for _ in range(20): x = random.randint(49846727467293, 249846727467293) soft, hard = resource.getrlimit(resource.RLIMIT_AS) resource.setrlimit(resource.RLIMIT_AS, (VMEM_LIMIT, hard)) From e4db172d1861adea399935cd445f84ecf6f16ddf Mon Sep 17 00:00:00 2001 From: Sergey B Kirpichev Date: Tue, 3 Feb 2026 02:49:42 +0300 Subject: [PATCH 3/6] Drop most pytest options --- .github/workflows/coverage.yml | 1 - pyproject.toml | 5 ++--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index e4e2f49a..183c3b08 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -5,7 +5,6 @@ jobs: timeout-minutes: 20 runs-on: ${{ matrix.os }} env: - PYTEST_ADDOPTS: --verbose CFLAGS: -Wall -Wpedantic -Werror -std=c17 -Wconversion strategy: matrix: diff --git a/pyproject.toml b/pyproject.toml index 3ebe6015..fdaac951 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -52,7 +52,6 @@ develop = ["python-gmp[tests,docs]", "pre-commit", "pyperf"] compile = ["--verbose"] [tool.pytest.ini_options] -addopts = "--durations=7 --capture=no" xfail_strict = true [tool.ruff] @@ -73,7 +72,7 @@ test-command = "pytest {package}" [tool.cibuildwheel.environment] LD_LIBRARY_PATH = "$(pwd)/.local/lib:$LD_LIBRARY_PATH" PKG_CONFIG_PATH = "$(pwd)/.local/lib/pkgconfig" -PYTEST_ADDOPTS = "--verbose -n 2" +PYTEST_ADDOPTS = "-n 2" CFLAGS = "-Wall -Wpedantic -Werror -Wconversion" [tool.cibuildwheel.windows] @@ -84,5 +83,5 @@ repair-wheel-command = """delvewheel repair -w {dest_dir} {wheel} \ --add-path .local/bin""" [tool.cibuildwheel.windows.environment] -PYTEST_ADDOPTS = "--verbose -n 2" +PYTEST_ADDOPTS = "-n 2" CFLAGS = "" From 2ec850060580eea7fc8d5a41ac3322d1df5341f6 Mon Sep 17 00:00:00 2001 From: Sergey B Kirpichev Date: Tue, 3 Feb 2026 03:28:42 +0300 Subject: [PATCH 4/6] Enable memory tests on PyPy --- tests/test_memory.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_memory.py b/tests/test_memory.py index ca0e533a..d19a14b1 100644 --- a/tests/test_memory.py +++ b/tests/test_memory.py @@ -13,11 +13,11 @@ if platform.python_implementation() == "GraalVM": pytest.skip("XXX: module 'resource' has no attribute 'setrlimit'", allow_module_level=True) -if platform.python_implementation() == "PyPy": - pytest.skip("XXX: diofant/python-gmp#73", allow_module_level=True) VMEM_LIMIT = 64*1000**2 resource = pytest.importorskip("resource") +if platform.python_implementation() == "PyPy": + VMEM_LIMIT = 128*1000**2 def test_fac_outofmem(): From 3fc073aca9013f57fd455ad9f724e3aa60c956bf Mon Sep 17 00:00:00 2001 From: Sergey B Kirpichev Date: Tue, 3 Feb 2026 06:24:31 +0300 Subject: [PATCH 5/6] Revert "Enable memory tests on PyPy" This reverts commit 2ec850060580eea7fc8d5a41ac3322d1df5341f6. --- tests/test_memory.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_memory.py b/tests/test_memory.py index d19a14b1..ca0e533a 100644 --- a/tests/test_memory.py +++ b/tests/test_memory.py @@ -13,11 +13,11 @@ if platform.python_implementation() == "GraalVM": pytest.skip("XXX: module 'resource' has no attribute 'setrlimit'", allow_module_level=True) +if platform.python_implementation() == "PyPy": + pytest.skip("XXX: diofant/python-gmp#73", allow_module_level=True) VMEM_LIMIT = 64*1000**2 resource = pytest.importorskip("resource") -if platform.python_implementation() == "PyPy": - VMEM_LIMIT = 128*1000**2 def test_fac_outofmem(): From 79e6baf7ae939a1cdca45d23df172e1733556655 Mon Sep 17 00:00:00 2001 From: Sergey B Kirpichev Date: Tue, 3 Feb 2026 06:26:28 +0300 Subject: [PATCH 6/6] Cleanup --- tests/test_memory.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tests/test_memory.py b/tests/test_memory.py index ca0e533a..fa95da63 100644 --- a/tests/test_memory.py +++ b/tests/test_memory.py @@ -14,7 +14,8 @@ pytest.skip("XXX: module 'resource' has no attribute 'setrlimit'", allow_module_level=True) if platform.python_implementation() == "PyPy": - pytest.skip("XXX: diofant/python-gmp#73", allow_module_level=True) + pytest.skip("See pypy/pypy#5147 and pypy/pypy#5325", + allow_module_level=True) VMEM_LIMIT = 64*1000**2 resource = pytest.importorskip("resource") @@ -56,8 +57,6 @@ def test_square_outofmem(): resource.setrlimit(resource.RLIMIT_AS, (soft, hard)) -@pytest.mark.skipif(platform.python_implementation() == "PyPy", - reason="XXX: pypy/pypy#5325") def test_square_with_threads(): soft, hard = resource.getrlimit(resource.RLIMIT_AS) def f(n, barrier):