def testSeek(self):
    file_object = fake_file_io.FakeFile(
        self._resolver_context, self._FILE_DATA2)
    file_object.open(path_spec=self._path_spec2)

    self.assertEqual(file_object.get_size(), 22)

    file_object.seek(10)
    self.assertEqual(file_object.read(5), b'other')
    self.assertEqual(file_object.get_offset(), 15)

    file_object.seek(-10, os.SEEK_END)
    self.assertEqual(file_object.read(5), b'her f')

    file_object.seek(2, os.SEEK_CUR)
    self.assertEqual(file_object.read(2), b'e.')

    # Conforming to the POSIX seek the offset can exceed the file size
    # but reading will result in no data being returned.
    file_object.seek(300, os.SEEK_SET)
    self.assertEqual(file_object.get_offset(), 300)
    self.assertEqual(file_object.read(2), b'')

    with self.assertRaises(IOError):
      file_object.seek(-10, os.SEEK_SET)

    # On error the offset should not change.
    self.assertEqual(file_object.get_offset(), 300)

    with self.assertRaises(IOError):
      file_object.seek(10, 5)

    # On error the offset should not change.
    self.assertEqual(file_object.get_offset(), 300)

    file_object.close()
Load the module with the tool-specific code.
dataset/ETHPy150Open log2timeline/dfvfs/tests/file_io/fake_file_io.py/FakeFileTest.testSeek--crossover with--dataset/ETHPy150Open sosy-lab/benchexec/benchexec/tablegenerator/__init__.py/load_tool