Skip to content

Commit 3244bb9

Browse files
committed
fix replace_fn fixture
1 parent 04e2c4e commit 3244bb9

File tree

1 file changed

+3
-22
lines changed

1 file changed

+3
-22
lines changed

tests/unit/test_struct.py

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import weakref
99
from contextlib import contextmanager
1010
from inspect import Parameter, Signature
11-
from typing import Any, Generic, List, Optional, TypeVar, Callable
11+
from typing import Any, Generic, List, Optional, TypeVar
1212

1313
import pytest
1414

@@ -26,25 +26,6 @@ def copy_replace(s, **changes):
2626
return s.__replace__(**changes)
2727

2828

29-
StructT = TypeVar("StructT", bound=Struct)
30-
31-
ReplaceFn = Callable[[StructT], StructT]
32-
33-
34-
@pytest.fixture(
35-
params=[
36-
pytest.param(msgspec.structs.replace, id="msgspec.replace"),
37-
pytest.param(
38-
copy_replace,
39-
id="copy.replace",
40-
marks=[pytest.mark.skipif("sys.version_info < (3, 13)")],
41-
),
42-
]
43-
)
44-
def replace_fn(request: pytest.FixtureRequest) -> ReplaceFn:
45-
return request.param
46-
47-
4829
@contextmanager
4930
def nogc():
5031
"""Temporarily disable GC"""
@@ -2682,7 +2663,7 @@ def __post_init__(self):
26822663
assert x1 == x2
26832664
assert count == 1
26842665

2685-
def test_post_init_called_on_replace(self, replace_fn: ReplaceFn):
2666+
def test_post_init_called_on_replace(self, replace):
26862667
count = 0
26872668

26882669
class Ex(Struct):
@@ -2692,6 +2673,6 @@ def __post_init__(self):
26922673

26932674
x1 = Ex()
26942675
assert count == 1
2695-
x2 = replace_fn(x1)
2676+
x2 = replace(x1)
26962677
assert x1 == x2
26972678
assert count == 2

0 commit comments

Comments
 (0)