def test_pickle_unpickle(self): from StringIO import StringIO as PickleableIO stream = PickleableIO('foo') runner = unittest.TextTestRunner(stream) for protocol in range(pickle.HIGHEST_PROTOCOL + 1): s = pickle.dumps(runner, protocol=protocol) obj = pickle.loads(s) self.assertEqual(obj.stream.getvalue(), stream.getvalue())
def test_pickle_unpickle(self): # Issue #7197: a TextTestRunner should be (un)pickleable. This is # required by test_multiprocessing under Windows (in verbose mode). from StringIO import StringIO as PickleableIO # cStringIO objects are not pickleable, but StringIO objects are. stream = PickleableIO("foo") runner = unittest.TextTestRunner(stream) for protocol in range(pickle.HIGHEST_PROTOCOL + 1): s = pickle.dumps(runner, protocol=protocol) obj = pickle.loads(s) # StringIO objects never compare equal, a cheap test instead. self.assertEqual(obj.stream.getvalue(), stream.getvalue())