diff options
author | Neal Norwitz <nnorwitz@gmail.com> | 2008-08-25 01:53:32 (GMT) |
---|---|---|
committer | Neal Norwitz <nnorwitz@gmail.com> | 2008-08-25 01:53:32 (GMT) |
commit | 5d6415ee26fcd663806ed3a19247573c5ca5f055 (patch) | |
tree | acaa227df26628da1b4598045a72707ed1adf33f | |
parent | c34177ccb2576df43ff3c772fe565a7439e32d3a (diff) | |
download | cpython-5d6415ee26fcd663806ed3a19247573c5ca5f055.zip cpython-5d6415ee26fcd663806ed3a19247573c5ca5f055.tar.gz cpython-5d6415ee26fcd663806ed3a19247573c5ca5f055.tar.bz2 |
Merged revisions 66023 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r66023 | neal.norwitz | 2008-08-24 18:50:24 -0700 (Sun, 24 Aug 2008) | 6 lines
Fix problem reported by pychecker where AuthenticationError wasn't imported.
Add some test coverage to this code. More tests should be added (TODO added).
R=Brett
TESTED=./python -E -tt ./Lib/test/regrtest.py test_multiprocessing
........
-rw-r--r-- | Lib/multiprocessing/connection.py | 2 | ||||
-rw-r--r-- | Lib/test/test_multiprocessing.py | 34 |
2 files changed, 34 insertions, 2 deletions
diff --git a/Lib/multiprocessing/connection.py b/Lib/multiprocessing/connection.py index b962060..1c4d48e 100644 --- a/Lib/multiprocessing/connection.py +++ b/Lib/multiprocessing/connection.py @@ -17,7 +17,7 @@ import tempfile import itertools import _multiprocessing -from multiprocessing import current_process +from multiprocessing import current_process, AuthenticationError from multiprocessing.util import get_temp_dir, Finalize, sub_debug, debug from multiprocessing.forking import duplicate, close diff --git a/Lib/test/test_multiprocessing.py b/Lib/test/test_multiprocessing.py index 102042d..891795d 100644 --- a/Lib/test/test_multiprocessing.py +++ b/Lib/test/test_multiprocessing.py @@ -1737,6 +1737,37 @@ class ThreadsMixin(object): testcases_threads = create_test_cases(ThreadsMixin, type='threads') globals().update(testcases_threads) +class OtherTest(unittest.TestCase): + # TODO: add more tests for deliver/answer challenge. + def test_deliver_challenge_auth_failure(self): + class _FakeConnection(object): + def recv_bytes(self, size): + return 'something bogus' + def send_bytes(self, data): + pass + self.assertRaises(multiprocessing.AuthenticationError, + multiprocessing.connection.deliver_challenge, + _FakeConnection(), b'abc') + + def test_answer_challenge_auth_failure(self): + class _FakeConnection(object): + def __init__(self): + self.count = 0 + def recv_bytes(self, size): + self.count += 1 + if self.count == 1: + return multiprocessing.connection.CHALLENGE + elif self.count == 2: + return 'something bogus' + return '' + def send_bytes(self, data): + pass + self.assertRaises(multiprocessing.AuthenticationError, + multiprocessing.connection.answer_challenge, + _FakeConnection(), b'abc') + +testcases_other = [OtherTest] + # # # @@ -1765,7 +1796,8 @@ def test_main(run=None): testcases = ( sorted(testcases_processes.values(), key=lambda tc:tc.__name__) + sorted(testcases_threads.values(), key=lambda tc:tc.__name__) + - sorted(testcases_manager.values(), key=lambda tc:tc.__name__) + sorted(testcases_manager.values(), key=lambda tc:tc.__name__) + + testcases_other ) loadTestsFromTestCase = unittest.defaultTestLoader.loadTestsFromTestCase |