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

Method test_ordered_dict

Lib/test/test_pprint.py:525–566  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

523 "[{'c': None, 'b': None, 'a': None}, {'c': None, 'b': None, 'a': None}]")
524
525 def test_ordered_dict(self):
526 d = collections.OrderedDict()
527 self.assertEqual(pprint.pformat(d, width=1), 'OrderedDict()')
528 d = collections.OrderedDict([])
529 self.assertEqual(pprint.pformat(d, width=1), 'OrderedDict()')
530 words = 'the quick brown fox jumped over a lazy dog'.split()
531 d = collections.OrderedDict(zip(words, itertools.count()))
532 self.assertEqual(pprint.pformat(d),
533"""\
534OrderedDict([('the', 0),
535 ('quick', 1),
536 ('brown', 2),
537 ('fox', 3),
538 ('jumped', 4),
539 ('over', 5),
540 ('a', 6),
541 ('lazy', 7),
542 ('dog', 8)])""")
543 self.assertEqual(pprint.pformat(d.keys(), sort_dicts=False),
544"""\
545odict_keys(['the',
546 'quick',
547 'brown',
548 'fox',
549 'jumped',
550 'over',
551 'a',
552 'lazy',
553 'dog'])""")
554 self.assertEqual(pprint.pformat(d.items(), sort_dicts=False),
555"""\
556odict_items([('the', 0),
557 ('quick', 1),
558 ('brown', 2),
559 ('fox', 3),
560 ('jumped', 4),
561 ('over', 5),
562 ('a', 6),
563 ('lazy', 7),
564 ('dog', 8)])""")
565 self.assertEqual(pprint.pformat(d.values(), sort_dicts=False),
566 "odict_values([0, 1, 2, 3, 4, 5, 6, 7, 8])")
567
568 def test_mapping_proxy(self):
569 words = 'the quick brown fox jumped over a lazy dog'.split()

Callers

nothing calls this directly

Calls 7

keysMethod · 0.95
itemsMethod · 0.95
valuesMethod · 0.95
pformatMethod · 0.80
assertEqualMethod · 0.45
splitMethod · 0.45
countMethod · 0.45

Tested by

no test coverage detected