@@ -67,6 +67,13 @@ class dict3(dict):
6767 def __repr__ (self ):
6868 return dict .__repr__ (self )
6969
70+ class frozendict2 (frozendict ):
71+ pass
72+
73+ class frozendict3 (frozendict ):
74+ def __repr__ (self ):
75+ return frozendict .__repr__ (self )
76+
7077class dict_custom_repr (dict ):
7178 def __repr__ (self ):
7279 return '*' * len (dict .__repr__ (self ))
@@ -254,18 +261,22 @@ def test_same_as_repr(self):
254261 set (), set2 (), set3 (),
255262 frozenset (), frozenset2 (), frozenset3 (),
256263 {}, dict2 (), dict3 (),
264+ frozendict (), frozendict2 (), frozendict3 (),
257265 {}.keys (), {}.values (), {}.items (),
258266 MappingView ({}), KeysView ({}), ItemsView ({}), ValuesView ({}),
259267 self .assertTrue , pprint ,
260268 - 6 , - 6 , - 6 - 6j , - 1.5 , "x" , b"x" , bytearray (b"x" ),
261269 (3 ,), [3 ], {3 : 6 },
262- (1 ,2 ), [3 ,4 ], { 5 : 6 },
270+ (1 ,2 ), [3 ,4 ],
263271 tuple2 ((1 ,2 )), tuple3 ((1 ,2 )), tuple3 (range (100 )),
264272 [3 ,4 ], list2 ([3 ,4 ]), list3 ([3 ,4 ]), list3 (range (100 )),
265273 set ({7 }), set2 ({7 }), set3 ({7 }),
266274 frozenset ({8 }), frozenset2 ({8 }), frozenset3 ({8 }),
267- dict2 ({5 : 6 }), dict3 ({5 : 6 }),
275+ {5 : 6 }, dict2 ({5 : 6 }), dict3 ({5 : 6 }),
276+ frozendict ({5 : 6 }), frozendict2 ({5 : 6 }), frozendict3 ({5 : 6 }),
268277 {5 : 6 }.keys (), {5 : 6 }.values (), {5 : 6 }.items (),
278+ frozendict ({5 : 6 }).keys (), frozendict ({5 : 6 }).values (),
279+ frozendict ({5 : 6 }).items (),
269280 MappingView ({5 : 6 }), KeysView ({5 : 6 }),
270281 ItemsView ({5 : 6 }), ValuesView ({5 : 6 }),
271282 range (10 , - 11 , - 1 ),
@@ -339,6 +350,15 @@ def test_basic_line_wrap(self):
339350 'read_io_runtime_us': 0,
340351 'write_io_runtime_us': 43690})"""
341352 self .assertEqual (pprint .pformat (frozendict (o )), exp )
353+ exp = """\
354+ frozendict2({'RPM_cal': 0,
355+ 'RPM_cal2': 48059,
356+ 'Speed_cal': 0,
357+ 'controldesk_runtime_us': 0,
358+ 'main_code_runtime_us': 0,
359+ 'read_io_runtime_us': 0,
360+ 'write_io_runtime_us': 43690})"""
361+ self .assertEqual (pprint .pformat (frozendict2 (o )), exp )
342362
343363 o = range (100 )
344364 exp = 'dict_keys([%s])' % ',\n ' .join (map (str , o ))
0 commit comments