MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / testSeekFromWhat

Method testSeekFromWhat

tensorflow/python/lib/io/file_io_test.py:431–453  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

429 self.assertEqual("testing2\n", f.readline())
430
431 def testSeekFromWhat(self):
432 file_path = os.path.join(self._base_dir, "temp_file")
433 with file_io.FileIO(file_path, mode="r+") as f:
434 f.write("testing1\ntesting2\ntesting3\n\ntesting5")
435 self.assertEqual("testing1\n", f.readline())
436 self.assertEqual(9, f.tell())
437
438 # Seek to 18
439 f.seek(9, 1)
440 self.assertEqual(18, f.tell())
441 self.assertEqual("testing3\n", f.readline())
442
443 # Seek back to 9
444 f.seek(9, 0)
445 self.assertEqual(9, f.tell())
446 self.assertEqual("testing2\n", f.readline())
447
448 f.seek(-f.size(), 2)
449 self.assertEqual(0, f.tell())
450 self.assertEqual("testing1\n", f.readline())
451
452 with self.assertRaises(errors.InvalidArgumentError):
453 f.seek(0, 3)
454
455 def testReadingIterator(self):
456 file_path = os.path.join(self._base_dir, "temp_file")

Callers

nothing calls this directly

Calls 6

readlineMethod · 0.80
tellMethod · 0.80
seekMethod · 0.80
joinMethod · 0.45
writeMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected