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

Method test_helper_function

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

Source from the content-addressed store, hash-verified

2375 self.assertIn("'b': None", r)
2376
2377 def test_helper_function(self):
2378 # two paths, one for real dicts and one for other mappings
2379 elems = list('abracadabra')
2380
2381 d = dict()
2382 _count_elements(d, elems)
2383 self.assertEqual(d, {'a': 5, 'r': 2, 'b': 2, 'c': 1, 'd': 1})
2384
2385 m = OrderedDict()
2386 _count_elements(m, elems)
2387 self.assertEqual(m,
2388 OrderedDict([('a', 5), ('b', 2), ('r', 2), ('c', 1), ('d', 1)]))
2389
2390 # test fidelity to the pure python version
2391 c = CounterSubclassWithSetItem('abracadabra')
2392 self.assertTrue(c.called)
2393 self.assertEqual(dict(c), {'a': 5, 'b': 2, 'c': 1, 'd': 1, 'r':2 })
2394 c = CounterSubclassWithGet('abracadabra')
2395 self.assertTrue(c.called)
2396 self.assertEqual(dict(c), {'a': 5, 'b': 2, 'c': 1, 'd': 1, 'r':2 })
2397
2398 def test_multiset_operations_equivalent_to_set_operations(self):
2399 # When the multiplicities are all zero or one, multiset operations

Callers

nothing calls this directly

Calls 7

_count_elementsFunction · 0.90
OrderedDictClass · 0.90
listClass · 0.85
assertTrueMethod · 0.80
assertEqualMethod · 0.45

Tested by

no test coverage detected