MCPcopy Create free account
hub / github.com/cloudpipe/cloudpickle / test_seek

Method test_seek

tests/cloudpickle_file_test.py:67–79  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

65 os.remove(self.tmpfilepath)
66
67 def test_seek(self):
68 # Write, then seek to arbitrary position
69 with open(self.tmpfilepath, "w+") as f:
70 f.write(self.teststring)
71 f.seek(4)
72 unpickled = pickle.loads(cloudpickle.dumps(f))
73 # unpickled StringIO is at position 4
74 self.assertEqual(4, unpickled.tell())
75 self.assertEqual(self.teststring[4:], unpickled.read())
76 # but unpickled StringIO also contained the start
77 unpickled.seek(0)
78 self.assertEqual(self.teststring, unpickled.read())
79 os.remove(self.tmpfilepath)
80
81 def test_pickling_special_file_handles(self):
82 # Warning: if you want to run your tests with nose, add -s option

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected