1
1
import sys
2
2
import pytest
3
3
import importlib .util
4
+ import dataclasses
4
5
5
6
6
7
def import_patch_module ():
@@ -10,7 +11,6 @@ def import_patch_module():
10
11
spec .loader .exec_module (mod )
11
12
return mod
12
13
13
-
14
14
def test_patch_module_emits_deprecation_warning ():
15
15
"""All Python versions: emits DeprecationWarning and defines compatibility symbols"""
16
16
with pytest .warns (DeprecationWarning ):
@@ -19,19 +19,9 @@ def test_patch_module_emits_deprecation_warning():
19
19
assert hasattr (mod , "DC_CREATE_FN" )
20
20
assert hasattr (mod , "dataclasses_init_fn_with_kwargs" )
21
21
assert mod .DC_CREATE_FN is False
22
- assert mod .dataclasses_init_fn_with_kwargs is None
23
-
24
22
25
- @pytest .mark .skipif (sys .version_info >= (3 , 13 ), reason = "dataclass patch behavior was only relevant pre-3.13" )
26
- def test_behavior_without_patch_pre_3_13 ():
27
- """Ensure standard dataclass behavior (no patch) in <3.13"""
28
- import dataclasses
23
+ # Check consistency with actual dataclasses module
24
+ init_fn = getattr (dataclasses , "_init_fn" , None )
25
+ assert mod .dataclasses_init_fn_with_kwargs == init_fn
29
26
30
- with pytest .raises (TypeError ):
31
- @dataclasses .dataclass
32
- class Example :
33
- a : int
34
- def __post_init__ (self , ** kwargs ): pass
35
27
36
- # This will fail because unknown kwarg 'extra' is not accepted
37
- Example (a = 1 , extra = "not allowed" )
0 commit comments