@@ -1197,6 +1197,18 @@ def make_weak_keyed_dict(self):
11971197 dict [o ] = o .arg
11981198 return dict , objects
11991199
1200+ def test_make_weak_valued_dict_misc (self ):
1201+ # errors
1202+ self .assertRaises (TypeError , weakref .WeakValueDictionary .__init__ )
1203+ self .assertRaises (TypeError , weakref .WeakValueDictionary , {}, {})
1204+ self .assertRaises (TypeError , weakref .WeakValueDictionary , (), ())
1205+ # special keyword arguments
1206+ o = Object (3 )
1207+ for kw in 'self' , 'other' , 'iterable' :
1208+ d = weakref .WeakValueDictionary (** {kw : o })
1209+ self .assertEqual (list (d .keys ()), [kw ])
1210+ self .assertEqual (d [kw ], o )
1211+
12001212 def make_weak_valued_dict (self ):
12011213 dict = weakref .WeakValueDictionary ()
12021214 objects = map (Object , range (self .COUNT ))
@@ -1279,6 +1291,19 @@ def check_update(self, klass, dict):
12791291 def test_weak_valued_dict_update (self ):
12801292 self .check_update (weakref .WeakValueDictionary ,
12811293 {1 : C (), 'a' : C (), C (): C ()})
1294+ # errors
1295+ self .assertRaises (TypeError , weakref .WeakValueDictionary .update )
1296+ d = weakref .WeakValueDictionary ()
1297+ self .assertRaises (TypeError , d .update , {}, {})
1298+ self .assertRaises (TypeError , d .update , (), ())
1299+ self .assertEqual (list (d .keys ()), [])
1300+ # special keyword arguments
1301+ o = Object (3 )
1302+ for kw in 'self' , 'dict' , 'other' , 'iterable' :
1303+ d = weakref .WeakValueDictionary ()
1304+ d .update (** {kw : o })
1305+ self .assertEqual (list (d .keys ()), [kw ])
1306+ self .assertEqual (d [kw ], o )
12821307
12831308 def test_weak_keyed_dict_update (self ):
12841309 self .check_update (weakref .WeakKeyDictionary ,
0 commit comments