| 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, |