MCPcopy Index your code
hub / github.com/RustPython/RustPython / test_deepcopy_weakvaluedict

Method test_deepcopy_weakvaluedict

Lib/test/test_copy.py:872–894  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

870 self.assertEqual(len(v), 1)
871
872 def test_deepcopy_weakvaluedict(self):
873 class C(object):
874 def __init__(self, i):
875 self.i = i
876 a, b, c, d = [C(i) for i in range(4)]
877 u = weakref.WeakValueDictionary()
878 u[a] = b
879 u[c] = d
880 # Keys are copied, values aren't
881 v = copy.deepcopy(u)
882 self.assertNotEqual(v, u)
883 self.assertEqual(len(v), 2)
884 (x, y), (z, t) = sorted(v.items(), key=lambda pair: pair[0].i)
885 self.assertIsNot(x, a)
886 self.assertEqual(x.i, a.i)
887 self.assertIs(y, b)
888 self.assertIsNot(z, c)
889 self.assertEqual(z.i, c.i)
890 self.assertIs(t, d)
891 del x, y, z, t
892 del d
893 support.gc_collect() # For PyPy or other GCs.
894 self.assertEqual(len(v), 1)
895
896 def test_deepcopy_bound_method(self):
897 class Foo(object):

Callers

nothing calls this directly

Calls 8

lenFunction · 0.85
sortedFunction · 0.85
assertNotEqualMethod · 0.80
assertIsNotMethod · 0.80
CClass · 0.70
assertEqualMethod · 0.45
itemsMethod · 0.45
assertIsMethod · 0.45

Tested by

no test coverage detected