MCPcopy Create free account
hub / github.com/pytorch/pytorch / test_pickle

Method test_pickle

test/test_datapipe.py:249–263  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

247 self.assertTrue(fd.closed)
248
249 def test_pickle(self):
250 with tempfile.TemporaryFile() as f:
251 with self.assertRaises(TypeError) as ctx1:
252 pickle.dumps(f)
253
254 wrap_f = StreamWrapper(f)
255 with self.assertRaises(TypeError) as ctx2:
256 pickle.dumps(wrap_f)
257
258 # Same exception when pickle
259 self.assertEqual(str(ctx1.exception), str(ctx2.exception))
260
261 fd = TestStreamWrapper._FakeFD("")
262 wrap_fd = StreamWrapper(fd)
263 _ = pickle.loads(pickle.dumps(wrap_fd))
264
265 def test_repr(self):
266 fd = TestStreamWrapper._FakeFD("")

Callers

nothing calls this directly

Calls 4

StreamWrapperClass · 0.90
assertRaisesMethod · 0.80
dumpsMethod · 0.80
assertEqualMethod · 0.45

Tested by

no test coverage detected