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

Method test_zero_byte_files

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

Source from the content-addressed store, hash-verified

177class FileInputTests(BaseTests, unittest.TestCase):
178
179 def test_zero_byte_files(self):
180 t1 = self.writeTmp("")
181 t2 = self.writeTmp("")
182 t3 = self.writeTmp("The only line there is.\n")
183 t4 = self.writeTmp("")
184 fi = FileInput(files=(t1, t2, t3, t4), encoding="utf-8")
185
186 line = fi.readline()
187 self.assertEqual(line, 'The only line there is.\n')
188 self.assertEqual(fi.lineno(), 1)
189 self.assertEqual(fi.filelineno(), 1)
190 self.assertEqual(fi.filename(), t3)
191
192 line = fi.readline()
193 self.assertFalse(line)
194 self.assertEqual(fi.lineno(), 1)
195 self.assertEqual(fi.filelineno(), 0)
196 self.assertEqual(fi.filename(), t4)
197 fi.close()
198
199 def test_files_that_dont_end_with_newline(self):
200 t1 = self.writeTmp("A\nB\nC")

Callers

nothing calls this directly

Calls 9

readlineMethod · 0.95
linenoMethod · 0.95
filelinenoMethod · 0.95
filenameMethod · 0.95
closeMethod · 0.95
FileInputClass · 0.90
writeTmpMethod · 0.80
assertFalseMethod · 0.80
assertEqualMethod · 0.45

Tested by

no test coverage detected