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

Method test_copying

Lib/test/test_collections.py:2219–2237  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

2217 self.assertRaises(TypeError, Counter.update)
2218
2219 def test_copying(self):
2220 # Check that counters are copyable, deepcopyable, picklable, and
2221 #have a repr/eval round-trip
2222 words = Counter('which witch had which witches wrist watch'.split())
2223 def check(dup):
2224 msg = "\ncopy: %s\nwords: %s" % (dup, words)
2225 self.assertIsNot(dup, words, msg)
2226 self.assertEqual(dup, words)
2227 check(words.copy())
2228 check(copy.copy(words))
2229 check(copy.deepcopy(words))
2230 for proto in range(pickle.HIGHEST_PROTOCOL + 1):
2231 with self.subTest(proto=proto):
2232 check(pickle.loads(pickle.dumps(words, proto)))
2233 check(eval(repr(words)))
2234 update_test = Counter()
2235 update_test.update(words)
2236 check(update_test)
2237 check(Counter(words))
2238
2239 def test_copy_subclass(self):
2240 class MyCounter(Counter):

Callers

nothing calls this directly

Calls 11

copyMethod · 0.95
updateMethod · 0.95
CounterClass · 0.90
reprFunction · 0.85
subTestMethod · 0.80
checkFunction · 0.70
evalFunction · 0.50
splitMethod · 0.45
copyMethod · 0.45
loadsMethod · 0.45
dumpsMethod · 0.45

Tested by

no test coverage detected