11import sys
22import pytest
33import importlib .util
4+ import dataclasses
45
56
67def import_patch_module ():
@@ -10,7 +11,6 @@ def import_patch_module():
1011 spec .loader .exec_module (mod )
1112 return mod
1213
13-
1414def test_patch_module_emits_deprecation_warning ():
1515 """All Python versions: emits DeprecationWarning and defines compatibility symbols"""
1616 with pytest .warns (DeprecationWarning ):
@@ -19,19 +19,9 @@ def test_patch_module_emits_deprecation_warning():
1919 assert hasattr (mod , "DC_CREATE_FN" )
2020 assert hasattr (mod , "dataclasses_init_fn_with_kwargs" )
2121 assert mod .DC_CREATE_FN is False
22- assert mod .dataclasses_init_fn_with_kwargs is None
23-
2422
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
2926
30- with pytest .raises (TypeError ):
31- @dataclasses .dataclass
32- class Example :
33- a : int
34- def __post_init__ (self , ** kwargs ): pass
3527
36- # This will fail because unknown kwarg 'extra' is not accepted
37- Example (a = 1 , extra = "not allowed" )
0 commit comments