Skip to content

Commit a53ec2e

Browse files
committed
Speed up PyPy CI tests
Backport of: #13724
1 parent d65e0f9 commit a53ec2e

7 files changed

Lines changed: 24 additions & 29 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -677,13 +677,20 @@ jobs:
677677
- run: mkdir coverage
678678

679679
- name: Run pytest
680+
if: '!startsWith(matrix.python-version, ''pypy'')'
680681
run: make test NUM_THREADS=${{ endsWith(matrix.python-version, 't') && '4' || '1' }}
681682
env:
682683
COVERAGE_FILE: coverage/.coverage.${{ runner.os }}-py${{ matrix.python-version }}
683684
CONTEXT: ${{ runner.os }}-py${{ matrix.python-version }}-without-deps
684685

686+
# Coverage is very slow on PyPy and it covers roughly the same lines as CPython tests:
687+
- name: Run pytest (no coverage)
688+
if: startsWith(matrix.python-version, 'pypy')
689+
run: uv run pytest --durations=10
690+
685691
- name: Store coverage files
686-
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
692+
if: '!startsWith(matrix.python-version, ''pypy'')'
693+
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
687694
with:
688695
name: coverage-${{ matrix.os }}-${{ matrix.python-version }}
689696
path: coverage

‎pydantic-core/tests/test_garbage_collection.py‎

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,7 @@
2121
)
2222

2323

24-
@pytest.mark.xfail(
25-
condition=platform.python_implementation() == 'PyPy', reason='https://github.com/pypy/pypy/issues/3898'
26-
)
24+
@pytest.mark.skipif(platform.python_implementation() == 'PyPy', reason='https://github.com/pypy/pypy/issues/3898')
2725
@pytest.mark.skipif(platform.python_implementation() == 'GraalVM', reason='Cannot reliably trigger GC on GraalPy')
2826
def test_gc_schema_serializer() -> None:
2927
"""https://github.com/pydantic/pydantic/issues/5136"""
@@ -50,9 +48,7 @@ class MyModel(BaseModel):
5048
assert_gc(lambda: len(cache) == 0)
5149

5250

53-
@pytest.mark.xfail(
54-
condition=platform.python_implementation() == 'PyPy', reason='https://github.com/pypy/pypy/issues/3898'
55-
)
51+
@pytest.mark.skipif(platform.python_implementation() == 'PyPy', reason='https://github.com/pypy/pypy/issues/3898')
5652
@pytest.mark.skipif(platform.python_implementation() == 'GraalVM', reason='Cannot reliably trigger GC on GraalPy')
5753
def test_gc_schema_validator() -> None:
5854
"""https://github.com/pydantic/pydantic/issues/5136"""
@@ -80,9 +76,7 @@ class MyModel(BaseModel):
8076
assert_gc(lambda: len(cache) == 0)
8177

8278

83-
@pytest.mark.xfail(
84-
condition=platform.python_implementation() == 'PyPy', reason='https://github.com/pypy/pypy/issues/3898'
85-
)
79+
@pytest.mark.skipif(platform.python_implementation() == 'PyPy', reason='https://github.com/pypy/pypy/issues/3898')
8680
@pytest.mark.skipif(platform.python_implementation() == 'GraalVM', reason='Cannot reliably trigger GC on GraalPy')
8781
def test_gc_validator_iterator() -> None:
8882
"""https://github.com/pydantic/pydantic/issues/9243"""
@@ -117,9 +111,7 @@ def __next__(self):
117111
assert_gc(lambda: len(cache) == 0)
118112

119113

120-
@pytest.mark.xfail(
121-
condition=platform.python_implementation() == 'PyPy', reason='https://github.com/pypy/pypy/issues/3898'
122-
)
114+
@pytest.mark.skipif(platform.python_implementation() == 'PyPy', reason='https://github.com/pypy/pypy/issues/3898')
123115
@pytest.mark.skipif(platform.python_implementation() == 'GraalVM', reason='Cannot reliably trigger GC on GraalPy')
124116
def test_gc_enum_serializer_class() -> None:
125117
"""https://github.com/pydantic/pydantic/issues/13621"""
@@ -143,9 +135,7 @@ class MyEnum(EnumBase, str, Enum):
143135
assert_gc(lambda: len(cache) == 0)
144136

145137

146-
@pytest.mark.xfail(
147-
condition=platform.python_implementation() == 'PyPy', reason='https://github.com/pypy/pypy/issues/3898'
148-
)
138+
@pytest.mark.skipif(platform.python_implementation() == 'PyPy', reason='https://github.com/pypy/pypy/issues/3898')
149139
@pytest.mark.skipif(platform.python_implementation() == 'GraalVM', reason='Cannot reliably trigger GC on GraalPy')
150140
def test_gc_enum_validator_lookup() -> None:
151141
"""https://github.com/pydantic/pydantic/issues/13621"""
@@ -169,9 +159,7 @@ class MyEnum(EnumBase, str, Enum):
169159
assert_gc(lambda: len(cache) == 0)
170160

171161

172-
@pytest.mark.xfail(
173-
condition=platform.python_implementation() == 'PyPy', reason='https://github.com/pypy/pypy/issues/3898'
174-
)
162+
@pytest.mark.skipif(platform.python_implementation() == 'PyPy', reason='https://github.com/pypy/pypy/issues/3898')
175163
@pytest.mark.skipif(platform.python_implementation() == 'GraalVM', reason='Cannot reliably trigger GC on GraalPy')
176164
def test_gc_field_exclude_if() -> None:
177165
"""https://github.com/pydantic/pydantic/issues/13621"""

‎pydantic-core/tests/validators/test_dataclasses.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1550,8 +1550,8 @@ def test_dataclass_wrap_json():
15501550
assert v.validate_json('{"a": "hello", "b": true}', strict=True) == FooDataclass(a='hello', b=True)
15511551

15521552

1553-
@pytest.mark.xfail(
1554-
condition=platform.python_implementation() == 'PyPy', reason='https://foss.heptapod.net/pypy/pypy/-/issues/3899'
1553+
@pytest.mark.skipif(
1554+
platform.python_implementation() == 'PyPy', reason='https://foss.heptapod.net/pypy/pypy/-/issues/3899'
15551555
)
15561556
@pytest.mark.skipif(platform.python_implementation() == 'GraalVM', reason='Cannot reliably trigger GC on GraalPy')
15571557
@pytest.mark.parametrize('validator', [None, 'field', 'dataclass'])

‎pydantic-core/tests/validators/test_model_init.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -411,8 +411,8 @@ def __init__(self, **kwargs):
411411
assert calls == ["{'a': '1'}", "{'a': '1', 'x': 4}"]
412412

413413

414-
@pytest.mark.xfail(
415-
condition=platform.python_implementation() == 'PyPy', reason='https://foss.heptapod.net/pypy/pypy/-/issues/3899'
414+
@pytest.mark.skipif(
415+
platform.python_implementation() == 'PyPy', reason='https://foss.heptapod.net/pypy/pypy/-/issues/3899'
416416
)
417417
@pytest.mark.skipif(platform.python_implementation() == 'GraalVM', reason='Cannot reliably trigger GC on GraalPy')
418418
@pytest.mark.parametrize('validator', [None, 'field', 'model'])

‎pydantic-core/tests/validators/test_nullable.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ def test_union_nullable_bool_int():
3939
assert v.validate_python(1) == 1
4040

4141

42-
@pytest.mark.xfail(
43-
condition=platform.python_implementation() == 'PyPy', reason='https://foss.heptapod.net/pypy/pypy/-/issues/3899'
42+
@pytest.mark.skipif(
43+
platform.python_implementation() == 'PyPy', reason='https://foss.heptapod.net/pypy/pypy/-/issues/3899'
4444
)
4545
@pytest.mark.skipif(platform.python_implementation() == 'GraalVM', reason='Cannot reliably trigger GC on GraalPy')
4646
def test_leak_nullable():

‎pydantic-core/tests/validators/test_typed_dict.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1208,8 +1208,8 @@ def test_extra_behavior_ignore(
12081208
assert m == {'f': 'x'}
12091209

12101210

1211-
@pytest.mark.xfail(
1212-
condition=platform.python_implementation() == 'PyPy', reason='https://foss.heptapod.net/pypy/pypy/-/issues/3899'
1211+
@pytest.mark.skipif(
1212+
platform.python_implementation() == 'PyPy', reason='https://foss.heptapod.net/pypy/pypy/-/issues/3899'
12131213
)
12141214
@pytest.mark.skipif(platform.python_implementation() == 'GraalVM', reason='Cannot reliably trigger GC on GraalPy')
12151215
def test_leak_typed_dict():

‎pydantic-core/tests/validators/test_with_default.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -646,8 +646,8 @@ def val_func(v: Any, handler: core_schema.ValidatorFunctionWrapHandler) -> Any:
646646
validator.validate_python('')
647647

648648

649-
@pytest.mark.xfail(
650-
condition=platform.python_implementation() == 'PyPy', reason='https://foss.heptapod.net/pypy/pypy/-/issues/3899'
649+
@pytest.mark.skipif(
650+
platform.python_implementation() == 'PyPy', reason='https://foss.heptapod.net/pypy/pypy/-/issues/3899'
651651
)
652652
@pytest.mark.skipif(platform.python_implementation() == 'GraalVM', reason='Cannot reliably trigger GC on GraalPy')
653653
def test_leak_with_default():

0 commit comments

Comments
 (0)