@@ -2130,22 +2130,30 @@ class Node(Generic[T]): ...
2130
2130
def test_immutability_by_copy_and_pickle (self ):
2131
2131
# Special forms like Union, Any, etc., generic aliases to containers like List,
2132
2132
# Mapping, etc., and type variabcles are considered immutable by copy and pickle.
2133
- global TP , TPB , TPV # for pickle
2133
+ global TP , TPB , TPV , PP # for pickle
2134
2134
TP = TypeVar ('TP' )
2135
2135
TPB = TypeVar ('TPB' , bound = int )
2136
2136
TPV = TypeVar ('TPV' , bytes , str )
2137
- for X in [TP , TPB , TPV , List , typing .Mapping , ClassVar , typing .Iterable ,
2137
+ PP = ParamSpec ('PP' )
2138
+ for X in [TP , TPB , TPV , PP ,
2139
+ List , typing .Mapping , ClassVar , typing .Iterable ,
2138
2140
Union , Any , Tuple , Callable ]:
2139
- self .assertIs (copy (X ), X )
2140
- self .assertIs (deepcopy (X ), X )
2141
- self .assertIs (pickle .loads (pickle .dumps (X )), X )
2141
+ with self .subTest (thing = X ):
2142
+ self .assertIs (copy (X ), X )
2143
+ self .assertIs (deepcopy (X ), X )
2144
+ for proto in range (pickle .HIGHEST_PROTOCOL + 1 ):
2145
+ self .assertIs (pickle .loads (pickle .dumps (X , proto )), X )
2146
+ del TP , TPB , TPV , PP
2147
+
2142
2148
# Check that local type variables are copyable.
2143
2149
TL = TypeVar ('TL' )
2144
2150
TLB = TypeVar ('TLB' , bound = int )
2145
2151
TLV = TypeVar ('TLV' , bytes , str )
2146
- for X in [TL , TLB , TLV ]:
2147
- self .assertIs (copy (X ), X )
2148
- self .assertIs (deepcopy (X ), X )
2152
+ PL = ParamSpec ('PL' )
2153
+ for X in [TL , TLB , TLV , PL ]:
2154
+ with self .subTest (thing = X ):
2155
+ self .assertIs (copy (X ), X )
2156
+ self .assertIs (deepcopy (X ), X )
2149
2157
2150
2158
def test_copy_generic_instances (self ):
2151
2159
T = TypeVar ('T' )
0 commit comments