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

Method test_builtin_list

Lib/test/test_iter.py:467–495  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

465
466 # Test list()'s use of iterators.
467 def test_builtin_list(self):
468 self.assertEqual(list(SequenceClass(5)), list(range(5)))
469 self.assertEqual(list(SequenceClass(0)), [])
470 self.assertEqual(list(()), [])
471
472 d = {"one": 1, "two": 2, "three": 3}
473 self.assertEqual(list(d), list(d.keys()))
474
475 self.assertRaises(TypeError, list, list)
476 self.assertRaises(TypeError, list, 42)
477
478 f = open(TESTFN, "w", encoding="utf-8")
479 try:
480 for i in range(5):
481 f.write("%d\n" % i)
482 finally:
483 f.close()
484 f = open(TESTFN, "r", encoding="utf-8")
485 try:
486 self.assertEqual(list(f), ["0\n", "1\n", "2\n", "3\n", "4\n"])
487 f.seek(0, 0)
488 self.assertEqual(list(f),
489 ["0\n", "1\n", "2\n", "3\n", "4\n"])
490 finally:
491 f.close()
492 try:
493 unlink(TESTFN)
494 except OSError:
495 pass
496
497 # Test tuples()'s use of iterators.
498 def test_builtin_tuple(self):

Callers

nothing calls this directly

Calls 10

assertEqualMethod · 0.95
assertRaisesMethod · 0.95
unlinkFunction · 0.90
listClass · 0.85
SequenceClassClass · 0.70
openFunction · 0.50
keysMethod · 0.45
writeMethod · 0.45
closeMethod · 0.45
seekMethod · 0.45

Tested by

no test coverage detected