@@ -1408,6 +1408,18 @@ def test_make_weak_valued_dict_from_weak_valued_dict(self):
14081408 dict2 = weakref .WeakValueDictionary (dict )
14091409 self .assertEqual (dict [364 ], o )
14101410
1411+ def test_make_weak_valued_dict_misc (self ):
1412+ # errors
1413+ self .assertRaises (TypeError , weakref .WeakValueDictionary .__init__ )
1414+ self .assertRaises (TypeError , weakref .WeakValueDictionary , {}, {})
1415+ self .assertRaises (TypeError , weakref .WeakValueDictionary , (), ())
1416+ # special keyword arguments
1417+ o = Object (3 )
1418+ for kw in 'self' , 'dict' , 'other' , 'iterable' :
1419+ d = weakref .WeakValueDictionary (** {kw : o })
1420+ self .assertEqual (list (d .keys ()), [kw ])
1421+ self .assertEqual (d [kw ], o )
1422+
14111423 def make_weak_valued_dict (self ):
14121424 dict = weakref .WeakValueDictionary ()
14131425 objects = list (map (Object , range (self .COUNT )))
@@ -1488,6 +1500,19 @@ def check_update(self, klass, dict):
14881500 def test_weak_valued_dict_update (self ):
14891501 self .check_update (weakref .WeakValueDictionary ,
14901502 {1 : C (), 'a' : C (), C (): C ()})
1503+ # errors
1504+ self .assertRaises (TypeError , weakref .WeakValueDictionary .update )
1505+ d = weakref .WeakValueDictionary ()
1506+ self .assertRaises (TypeError , d .update , {}, {})
1507+ self .assertRaises (TypeError , d .update , (), ())
1508+ self .assertEqual (list (d .keys ()), [])
1509+ # special keyword arguments
1510+ o = Object (3 )
1511+ for kw in 'self' , 'dict' , 'other' , 'iterable' :
1512+ d = weakref .WeakValueDictionary ()
1513+ d .update (** {kw : o })
1514+ self .assertEqual (list (d .keys ()), [kw ])
1515+ self .assertEqual (d [kw ], o )
14911516
14921517 def test_weak_keyed_dict_update (self ):
14931518 self .check_update (weakref .WeakKeyDictionary ,
0 commit comments