From 58a13f326f9cab8be03c56c514e7347546537a9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= Date: Fri, 15 Dec 2023 17:45:42 +0100 Subject: [PATCH 1/3] Support SETUPPY_FORCE_PURE in tests Support testing without the C extension if SETUPPY_FORCE_PURE is set. This makes the test suite behavior consistent with setup.py behavior. --- tests/conftest.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/conftest.py b/tests/conftest.py index 1317faf..383289c 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,3 +1,4 @@ +import os import sys import pytest @@ -19,7 +20,7 @@ class FakeModule: try: from lazy_object_proxy.cext import Proxy except ImportError: - if PYPY: + if PYPY or os.environ.get('SETUPPY_FORCE_PURE'): pytest.skip(reason='C Extension not available.') else: raise From 9ba6f66b5959fa9739c7224e3ee3c5505fafc799 Mon Sep 17 00:00:00 2001 From: Michael Simacek Date: Thu, 22 May 2025 14:53:04 +0200 Subject: [PATCH 2/3] Skip C extension build on GraalPy --- setup.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index 2cd958f..3cbc50e 100755 --- a/setup.py +++ b/setup.py @@ -22,8 +22,8 @@ LFLAGS = '' allow_extensions = True -if '__pypy__' in sys.builtin_module_names: - print('NOTICE: C extensions disabled on PyPy (would be broken)!') +if sys.implementation.name in ('pypy', 'graalpy'): + print('NOTICE: C extensions disabled on PyPy/GraalPy (would be broken)!') allow_extensions = False if os.environ.get('SETUPPY_FORCE_PURE'): print('NOTICE: C extensions disabled (SETUPPY_FORCE_PURE)!') From 4db87e64b26f427d1af5e26f2835110e53544202 Mon Sep 17 00:00:00 2001 From: Michael Simacek Date: Fri, 23 May 2025 18:01:23 +0200 Subject: [PATCH 3/3] Test GraalPy in the CI --- .github/workflows/github-actions.yml | 18 ++++++++++++++++++ tests/conftest.py | 3 ++- tests/test_async_py3.py | 12 ++++++++++++ tests/test_lazy_object_proxy.py | 4 ++++ tox.ini | 3 ++- 5 files changed, 38 insertions(+), 2 deletions(-) diff --git a/.github/workflows/github-actions.yml b/.github/workflows/github-actions.yml index 446b4da..29983d8 100644 --- a/.github/workflows/github-actions.yml +++ b/.github/workflows/github-actions.yml @@ -673,6 +673,24 @@ jobs: cibw_arch: 'arm64' cibw_build: false os: 'macos-latest' + - name: 'graalpy242-nocov (ubuntu/x86_64/manylinux)' + artifact: 'graalpy242-ubuntu-x86_64-manylinux' + python: 'graalpy-24.2' + toxpython: 'graalpy' + python_arch: 'x64' + tox_env: 'graalpy-nocov' + cibw_arch: 'x86_64' + cibw_build: false + os: 'ubuntu-latest' + - name: 'graalpy242-nocov (macos/arm64)' + artifact: 'graalpy242-macos-arm64' + python: 'graalpy-24.2' + toxpython: 'graalpy' + python_arch: 'arm64' + tox_env: 'graalpy-nocov' + cibw_arch: 'arm64' + cibw_build: false + os: 'macos-latest' steps: - uses: docker/setup-qemu-action@v3 if: matrix.cibw_arch == 'aarch64' diff --git a/tests/conftest.py b/tests/conftest.py index 383289c..1289733 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -4,6 +4,7 @@ import pytest PYPY = '__pypy__' in sys.builtin_module_names +GRAALPY = sys.implementation.name == 'graalpy' @pytest.fixture(scope='session') @@ -20,7 +21,7 @@ class FakeModule: try: from lazy_object_proxy.cext import Proxy except ImportError: - if PYPY or os.environ.get('SETUPPY_FORCE_PURE'): + if PYPY or GRAALPY or os.environ.get('SETUPPY_FORCE_PURE'): pytest.skip(reason='C Extension not available.') else: raise diff --git a/tests/test_async_py3.py b/tests/test_async_py3.py index 0d9450b..235cf2f 100644 --- a/tests/test_async_py3.py +++ b/tests/test_async_py3.py @@ -13,6 +13,7 @@ from lazy_object_proxy.utils import await_ pypyxfail = pytest.mark.xfail('hasattr(sys, "pypy_version_info")') +graalpyxfail = pytest.mark.xfail('sys.implementation.name == "graalpy"') class AsyncYieldFrom: @@ -75,6 +76,7 @@ def gen(): assert not hasattr(gen, '__await__') +@graalpyxfail def test_func_1(lop): async def foo(): return 10 @@ -95,6 +97,7 @@ def bar(): assert not bool(bar.__code__.co_flags & inspect.CO_COROUTINE) +@graalpyxfail def test_func_2(lop): async def foo(): raise StopIteration @@ -269,6 +272,7 @@ async def func(): coro.close() +@graalpyxfail def test_func_12(lop): async def g(): i = me.send(None) @@ -279,6 +283,7 @@ async def g(): me.send(None) +@graalpyxfail def test_func_13(lop): async def g(): pass @@ -290,6 +295,7 @@ async def g(): coro.close() +@graalpyxfail def test_func_14(lop): @types.coroutine def gen(): @@ -777,6 +783,7 @@ async def foo(): run_async(lop.Proxy(foo)) +@graalpyxfail def test_with_2(lop): class CM: def __aenter__(self): @@ -845,6 +852,7 @@ async def func(): @pypyxfail +@graalpyxfail def test_with_6(lop): class CM: def __aenter__(self): @@ -863,6 +871,7 @@ async def foo(): @pypyxfail +@graalpyxfail def test_with_7(lop): class CM: async def __aenter__(self): @@ -887,6 +896,7 @@ async def foo(): @pypyxfail +@graalpyxfail def test_with_8(lop): CNT = 0 @@ -990,6 +1000,7 @@ async def foo(): pytest.fail('exception from __aexit__ did not propagate') +@graalpyxfail def test_with_11(lop): CNT = 0 @@ -1032,6 +1043,7 @@ async def foo(): run_async(lop.Proxy(foo)) +@graalpyxfail def test_with_13(lop): CNT = 0 diff --git a/tests/test_lazy_object_proxy.py b/tests/test_lazy_object_proxy.py index 5f88394..4140c10 100644 --- a/tests/test_lazy_object_proxy.py +++ b/tests/test_lazy_object_proxy.py @@ -14,6 +14,8 @@ PYPY = '__pypy__' in sys.builtin_module_names +graalpyxfail = pytest.mark.xfail('sys.implementation.name == "graalpy"') + OBJECTS_CODE = """ class TargetBaseClass(object): "documentation" @@ -223,6 +225,7 @@ def test_function_doc_string(lop): assert wrapper.__doc__ == target.__doc__ +@graalpyxfail def test_class_of_class(lop): # Test preservation of class __class__ attribute. @@ -271,6 +274,7 @@ def test_class_of_instance(lop): assert isinstance(wrapper, objects.TargetBaseClass) +@graalpyxfail def test_class_of_function(lop): # Test preservation of function __class__ attribute. diff --git a/tox.ini b/tox.ini index dbe24b9..56c22c9 100644 --- a/tox.ini +++ b/tox.ini @@ -14,7 +14,7 @@ envlist = clean, check, docs, - {py39,py310,py311,py312,py313,py313-ft,pypy39,pypy310}-{cover,nocov}, + {py39,py310,py311,py312,py313,py313-ft,pypy39,pypy310,graalpy}-{cover,nocov}, report ignore_basepython_conflict = true @@ -28,6 +28,7 @@ basepython = py312: {env:TOXPYTHON:python3.12} py313: {env:TOXPYTHON:python3.13} py313ft: {env:TOXPYTHON:python3.13t} + graalpy: {env:TOXPYTHON:graalpy} {bootstrap,clean,check,report,docs,codecov,coveralls,extension-coveralls}: {env:TOXPYTHON:python3} setenv = PYTHONPATH={toxinidir}/tests