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

Method testSeek

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

Source from the content-addressed store, hash-verified

395 self.assertEqual(36, f.tell())
396
397 def testSeek(self):
398 file_path = os.path.join(self._base_dir, "temp_file")
399 with file_io.FileIO(file_path, mode="r+") as f:
400 f.write("testing1\ntesting2\ntesting3\n\ntesting5")
401 self.assertEqual("testing1\n", f.readline())
402 self.assertEqual(9, f.tell())
403
404 # Seek to 18
405 f.seek(18)
406 self.assertEqual(18, f.tell())
407 self.assertEqual("testing3\n", f.readline())
408
409 # Seek back to 9
410 f.seek(9)
411 self.assertEqual(9, f.tell())
412 self.assertEqual("testing2\n", f.readline())
413
414 f.seek(0)
415 self.assertEqual(0, f.tell())
416 self.assertEqual("testing1\n", f.readline())
417
418 with self.assertRaises(errors.InvalidArgumentError):
419 f.seek(-1)
420
421 with self.assertRaises(TypeError):
422 f.seek()
423
424 # TODO(jhseu): Delete after position deprecation.
425 with self.assertRaises(TypeError):
426 f.seek(offset=0, position=0)
427 f.seek(position=9)
428 self.assertEqual(9, f.tell())
429 self.assertEqual("testing2\n", f.readline())
430
431 def testSeekFromWhat(self):
432 file_path = os.path.join(self._base_dir, "temp_file")

Callers

nothing calls this directly

Calls 5

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

Tested by

no test coverage detected