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

Method test_iter_file

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

Source from the content-addressed store, hash-verified

446
447 # Test a file
448 def test_iter_file(self):
449 f = open(TESTFN, "w", encoding="utf-8")
450 try:
451 for i in range(5):
452 f.write("%d\n" % i)
453 finally:
454 f.close()
455 f = open(TESTFN, "r", encoding="utf-8")
456 try:
457 self.check_for_loop(f, ["0\n", "1\n", "2\n", "3\n", "4\n"], pickle=False)
458 self.check_for_loop(f, [], pickle=False)
459 finally:
460 f.close()
461 try:
462 unlink(TESTFN)
463 except OSError:
464 pass
465
466 # Test list()'s use of iterators.
467 def test_builtin_list(self):

Callers

nothing calls this directly

Calls 5

check_for_loopMethod · 0.95
unlinkFunction · 0.90
openFunction · 0.50
writeMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected