MCPcopy Index your code
hub / github.com/python/cpython / check_update

Method check_update

Lib/test/test_weakref.py:1742–1759  ·  view source on GitHub ↗
(self, klass, dict)

Source from the content-addressed store, hash-verified

1740 C(), "value 1", "value 2")
1741
1742 def check_update(self, klass, dict):
1743 #
1744 # This exercises d.update(), len(d), d.keys(), k in d,
1745 # d.get(), d[].
1746 #
1747 weakdict = klass()
1748 weakdict.update(dict)
1749 self.assertEqual(len(weakdict), len(dict))
1750 for k in weakdict.keys():
1751 self.assertIn(k, dict, "mysterious new key appeared in weak dict")
1752 v = dict.get(k)
1753 self.assertIs(v, weakdict[k])
1754 self.assertIs(v, weakdict.get(k))
1755 for k in dict.keys():
1756 self.assertIn(k, weakdict, "original key disappeared in weak dict")
1757 v = dict[k]
1758 self.assertIs(v, weakdict[k])
1759 self.assertIs(v, weakdict.get(k))
1760
1761 def test_weak_valued_dict_update(self):
1762 self.check_update(weakref.WeakValueDictionary,

Callers 2

Calls 6

assertInMethod · 0.80
updateMethod · 0.45
assertEqualMethod · 0.45
keysMethod · 0.45
getMethod · 0.45
assertIsMethod · 0.45

Tested by

no test coverage detected