summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_unittest.py
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2009-11-10 21:34:48 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2009-11-10 21:34:48 (GMT)
commitc63ecee6c33156cbae1f985d49f6aa995af04f21 (patch)
treea4d2c7b066ec4ce2bba6d789383f584c7905b9ed /Lib/test/test_unittest.py
parentadf6a6c8421b12ef84b25b1b7628226912051cc2 (diff)
downloadcpython-c63ecee6c33156cbae1f985d49f6aa995af04f21.zip
cpython-c63ecee6c33156cbae1f985d49f6aa995af04f21.tar.gz
cpython-c63ecee6c33156cbae1f985d49f6aa995af04f21.tar.bz2
Merged revisions 76196 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r76196 | antoine.pitrou | 2009-11-10 21:49:30 +0100 (mar., 10 nov. 2009) | 8 lines Issue #7197: Allow unittest.TextTestRunner objects to be pickled and unpickled. This fixes crashes under Windows when trying to run test_multiprocessing in verbose mode. Additionally, Test_TextTestRunner hadn't been enabled in test_unittest. ........
Diffstat (limited to 'Lib/test/test_unittest.py')
-rw-r--r--Lib/test/test_unittest.py14
1 files changed, 13 insertions, 1 deletions
diff --git a/Lib/test/test_unittest.py b/Lib/test/test_unittest.py
index b6100b1..9cdca96 100644
--- a/Lib/test/test_unittest.py
+++ b/Lib/test/test_unittest.py
@@ -17,6 +17,7 @@ from unittest import TestCase, TestProgram
import types
from copy import deepcopy
import io
+import pickle
### Support code
################################################################
@@ -3441,6 +3442,17 @@ class Test_TextTestRunner(TestCase):
expected = ['startTestRun', 'stopTestRun']
self.assertEqual(events, expected)
+ def test_pickle_unpickle(self):
+ # Issue #7197: a TextTestRunner should be (un)pickleable. This is
+ # required by test_multiprocessing under Windows (in verbose mode).
+ stream = io.StringIO("foo")
+ runner = unittest.TextTestRunner(stream)
+ for protocol in range(2, pickle.HIGHEST_PROTOCOL + 1):
+ s = pickle.dumps(runner, protocol)
+ obj = pickle.loads(s)
+ # StringIO objects never compare equal, a cheap test instead.
+ self.assertEqual(obj.stream.getvalue(), stream.getvalue())
+
class TestDiscovery(TestCase):
@@ -3729,7 +3741,7 @@ def test_main():
support.run_unittest(Test_TestCase, Test_TestLoader,
Test_TestSuite, Test_TestResult, Test_FunctionTestCase,
Test_TestSkipping, Test_Assertions, TestLongMessage,
- Test_TestProgram, TestCleanUp, TestDiscovery)
+ Test_TestProgram, TestCleanUp, TestDiscovery, Test_TextTestRunner)
if __name__ == "__main__":
test_main()