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

Method test_context_manager

Lib/test/test_fileinput.py:346–354  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

344 self.assertEqual(result, "I used to receive only filename and mode")
345
346 def test_context_manager(self):
347 t1 = self.writeTmp("A\nB\nC")
348 t2 = self.writeTmp("D\nE\nF")
349 with FileInput(files=(t1, t2), encoding="utf-8") as fi:
350 lines = list(fi)
351 self.assertEqual(lines, ["A\n", "B\n", "C", "D\n", "E\n", "F"])
352 self.assertEqual(fi.filelineno(), 3)
353 self.assertEqual(fi.lineno(), 6)
354 self.assertEqual(fi._files, ())
355
356 def test_close_on_exception(self):
357 t1 = self.writeTmp("")

Callers

nothing calls this directly

Calls 6

FileInputClass · 0.90
listClass · 0.85
writeTmpMethod · 0.80
assertEqualMethod · 0.45
filelinenoMethod · 0.45
linenoMethod · 0.45

Tested by

no test coverage detected