diff options
| author | Neal Norwitz <nnorwitz@gmail.com> | 2008-08-25 01:50:24 (GMT) | 
|---|---|---|
| committer | Neal Norwitz <nnorwitz@gmail.com> | 2008-08-25 01:50:24 (GMT) | 
| commit | 0c519b3a5e847eea0dffb51ac8df7c68891daf70 (patch) | |
| tree | a120933ac036950f8e2a7e8b5a482858f672ce7a /Lib/test/test_multiprocessing.py | |
| parent | 971f10210ef593cd620af6c2178ed8265fb86946 (diff) | |
| download | cpython-0c519b3a5e847eea0dffb51ac8df7c68891daf70.zip cpython-0c519b3a5e847eea0dffb51ac8df7c68891daf70.tar.gz cpython-0c519b3a5e847eea0dffb51ac8df7c68891daf70.tar.bz2  | |
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
Diffstat (limited to 'Lib/test/test_multiprocessing.py')
| -rw-r--r-- | Lib/test/test_multiprocessing.py | 34 | 
1 files changed, 33 insertions, 1 deletions
diff --git a/Lib/test/test_multiprocessing.py b/Lib/test/test_multiprocessing.py index b13d1da..d64c561 100644 --- a/Lib/test/test_multiprocessing.py +++ b/Lib/test/test_multiprocessing.py @@ -1736,6 +1736,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] +  #  #  # @@ -1764,7 +1795,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  | 
