~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_transport.py

Merge smart-server-leaks into sftp-leaks fixing conflicts

Show diffs side-by-side

added added

removed removed

Lines of Context:
993
993
        # And the rest are threads
994
994
        for t in started[1:]:
995
995
            t.join()
996
 
 
997
 
 
998
 
class TestThreadWithException(tests.TestCase):
999
 
 
1000
 
    def test_start_and_join_smoke_test(self):
1001
 
        def do_nothing():
1002
 
            pass
1003
 
 
1004
 
        tt = test_server.ThreadWithException(target=do_nothing)
1005
 
        tt.start()
1006
 
        tt.join()
1007
 
 
1008
 
    def test_exception_is_re_raised(self):
1009
 
        class MyException(Exception):
1010
 
            pass
1011
 
 
1012
 
        def raise_my_exception():
1013
 
            raise MyException()
1014
 
 
1015
 
        tt = test_server.ThreadWithException(target=raise_my_exception)
1016
 
        tt.start()
1017
 
        self.assertRaises(MyException, tt.join)
1018
 
 
1019
 
    def test_join_when_no_exception(self):
1020
 
        resume = threading.Event()
1021
 
        class MyException(Exception):
1022
 
            pass
1023
 
 
1024
 
        def raise_my_exception():
1025
 
            # Wait for the test to tell us to resume
1026
 
            resume.wait()
1027
 
            # Now we can raise
1028
 
            raise MyException()
1029
 
 
1030
 
        tt = test_server.ThreadWithException(target=raise_my_exception)
1031
 
        tt.start()
1032
 
        tt.join(timeout=0)
1033
 
        self.assertIs(None, tt.exception)
1034
 
        resume.set()
1035
 
        self.assertRaises(MyException, tt.join)