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

Method test_copying

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

Source from the content-addressed store, hash-verified

2237 self.assertRaises(TypeError, Counter.update)
2238
2239 def test_copying(self):
2240 # Check that counters are copyable, deepcopyable, picklable, and
2241 #have a repr/eval round-trip
2242 words = Counter('which witch had which witches wrist watch'.split())
2243 def check(dup):
2244 msg = "\ncopy: %s\nwords: %s" % (dup, words)
2245 self.assertIsNot(dup, words, msg)
2246 self.assertEqual(dup, words)
2247 check(words.copy())
2248 check(copy.copy(words))
2249 check(copy.deepcopy(words))
2250 for proto in range(pickle.HIGHEST_PROTOCOL + 1):
2251 with self.subTest(proto=proto):
2252 check(pickle.loads(pickle.dumps(words, proto)))
2253 check(eval(repr(words)))
2254 update_test = Counter()
2255 update_test.update(words)
2256 check(update_test)
2257 check(Counter(words))
2258
2259 def test_copy_subclass(self):
2260 class MyCounter(Counter):

Callers

nothing calls this directly

Calls 9

copyMethod · 0.95
updateMethod · 0.95
CounterClass · 0.90
checkFunction · 0.70
splitMethod · 0.45
copyMethod · 0.45
subTestMethod · 0.45
loadsMethod · 0.45
dumpsMethod · 0.45

Tested by

no test coverage detected