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

Method test_dicts

Lib/test/test_descr.py:201–228  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

199 "__setitem__")
200
201 def test_dicts(self):
202 # Testing dict operations...
203 self.binop_test({1:2,3:4}, 1, 1, "b in a", "__contains__")
204 self.binop_test({1:2,3:4}, 2, 0, "b in a", "__contains__")
205 self.binop_test({1:2,3:4}, 1, 2, "a[b]", "__getitem__")
206
207 d = {1:2, 3:4}
208 l1 = []
209 for i in list(d.keys()):
210 l1.append(i)
211 l = []
212 for i in iter(d):
213 l.append(i)
214 self.assertEqual(l, l1)
215 l = []
216 for i in d.__iter__():
217 l.append(i)
218 self.assertEqual(l, l1)
219 l = []
220 for i in dict.__iter__(d):
221 l.append(i)
222 self.assertEqual(l, l1)
223 d = {1:2, 3:4}
224 self.unop_test(d, 2, "len(a)", "__len__")
225 self.assertEqual(eval(repr(d), {}), d)
226 self.assertEqual(eval(d.__repr__(), {}), d)
227 self.set2op_test({1:2,3:4}, 2, 3, {1:2,2:3,3:4}, "a[b]=c",
228 "__setitem__")
229
230 # Tests for unary and binary operators
231 def number_operators(self, a, b, skip=[]):

Callers

nothing calls this directly

Calls 9

binop_testMethod · 0.95
unop_testMethod · 0.95
set2op_testMethod · 0.95
listClass · 0.85
keysMethod · 0.45
appendMethod · 0.45
assertEqualMethod · 0.45
__iter__Method · 0.45
__repr__Method · 0.45

Tested by

no test coverage detected