summaryrefslogtreecommitdiff
path: root/tests/test_runner/test_parallel.py
diff options
context:
space:
mode:
authorAdam Wróbel <adam@adamwrobel.com>2016-10-06 21:54:38 +0200
committerTim Graham <timograham@gmail.com>2016-10-06 15:54:38 -0400
commit52188a5ca6bafea0a66f17baacb315d61c7b99cd (patch)
tree1a612c81a9203902faeeecc41a0ff10698f8cda3 /tests/test_runner/test_parallel.py
parent9cfd060b1c0c3664d77e4ab30a6c351822f0a4d6 (diff)
downloaddjango-52188a5ca6bafea0a66f17baacb315d61c7b99cd.tar.gz
Fixed #27301 -- Prevented exceptions that fail unpickling from crashing the parallel test runner.
Diffstat (limited to 'tests/test_runner/test_parallel.py')
-rw-r--r--tests/test_runner/test_parallel.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/test_runner/test_parallel.py b/tests/test_runner/test_parallel.py
index 529fe22092..8118734994 100644
--- a/tests/test_runner/test_parallel.py
+++ b/tests/test_runner/test_parallel.py
@@ -10,6 +10,15 @@ except ImportError:
tblib = None
+class ExceptionThatFailsUnpickling(Exception):
+ """
+ After pickling, this class fails unpickling with an error about incorrect
+ arguments passed to __init__().
+ """
+ def __init__(self, arg):
+ super(ExceptionThatFailsUnpickling, self).__init__()
+
+
class ParallelTestRunnerTest(SimpleTestCase):
"""
End-to-end tests of the parallel test runner.
@@ -44,6 +53,19 @@ class SampleFailingSubtest(SimpleTestCase):
class RemoteTestResultTest(SimpleTestCase):
+ def test_pickle_errors_detection(self):
+ picklable_error = RuntimeError('This is fine')
+ not_unpicklable_error = ExceptionThatFailsUnpickling('arg')
+
+ result = RemoteTestResult()
+ result._confirm_picklable(picklable_error)
+
+ msg = '__init__() missing 1 required positional argument'
+ if six.PY2:
+ msg = '__init__() takes exactly 2 arguments (1 given)'
+ with self.assertRaisesMessage(TypeError, msg):
+ result._confirm_picklable(not_unpicklable_error)
+
@unittest.skipUnless(six.PY3 and tblib is not None, 'requires tblib to be installed')
def test_add_failing_subtests(self):
"""