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

Method test_dict_repr

Lib/test/test_dictviews.py:75–89  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

73 self.assertEqual(len(values), 2)
74
75 def test_dict_repr(self):
76 d = {1: 10, "a": "ABC"}
77 self.assertIsInstance(repr(d), str)
78 r = repr(d.items())
79 self.assertIsInstance(r, str)
80 self.assertTrue(r == "dict_items([('a', 'ABC'), (1, 10)])" or
81 r == "dict_items([(1, 10), ('a', 'ABC')])")
82 r = repr(d.keys())
83 self.assertIsInstance(r, str)
84 self.assertTrue(r == "dict_keys(['a', 1])" or
85 r == "dict_keys([1, 'a'])")
86 r = repr(d.values())
87 self.assertIsInstance(r, str)
88 self.assertTrue(r == "dict_values(['ABC', 10])" or
89 r == "dict_values([10, 'ABC'])")
90
91 def test_keys_set_operations(self):
92 d1 = {'a': 1, 'b': 2}

Callers

nothing calls this directly

Calls 5

assertIsInstanceMethod · 0.80
assertTrueMethod · 0.80
itemsMethod · 0.45
keysMethod · 0.45
valuesMethod · 0.45

Tested by

no test coverage detected