MCPcopy Index your code
hub / github.com/mongodb/mongo-python-driver / test_seek

Method test_seek

test/test_grid_file.py:437–462  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

435 qcheck.check_unittest(self, helper, qcheck.gen_string(qcheck.gen_range(0, 20)))
436
437 def test_seek(self):
438 f = GridIn(self.db.fs, chunkSize=3)
439 f.write(b"hello world")
440 f.close()
441
442 g = GridOut(self.db.fs, f._id)
443 self.assertEqual(b"hello world", g.read())
444 g.seek(0)
445 self.assertEqual(b"hello world", g.read())
446 g.seek(1)
447 self.assertEqual(b"ello world", g.read())
448 with self.assertRaises(IOError):
449 g.seek(-1)
450
451 g.seek(-3, _SEEK_END)
452 self.assertEqual(b"rld", g.read())
453 g.seek(0, _SEEK_END)
454 self.assertEqual(b"", g.read())
455 with self.assertRaises(IOError):
456 g.seek(-100, _SEEK_END)
457
458 g.seek(3)
459 g.seek(3, _SEEK_CUR)
460 self.assertEqual(b"world", g.read())
461 with self.assertRaises(IOError):
462 g.seek(-100, _SEEK_CUR)
463
464 def test_tell(self):
465 f = GridIn(self.db.fs, chunkSize=3)

Callers

nothing calls this directly

Calls 6

writeMethod · 0.95
closeMethod · 0.95
readMethod · 0.95
seekMethod · 0.95
GridInClass · 0.90
GridOutClass · 0.90

Tested by

no test coverage detected