Rev 5292: Move tests related to TestThreadWithException in test_test_server. in file:///home/vila/src/bzr/experimental/leaking-tests/

Vincent Ladeuil v.ladeuil+lp at free.fr
Wed Jun 23 16:30:05 BST 2010


At file:///home/vila/src/bzr/experimental/leaking-tests/

------------------------------------------------------------
revno: 5292
revision-id: v.ladeuil+lp at free.fr-20100623153004-z0y8qjrn10idme4s
parent: v.ladeuil+lp at free.fr-20100623152259-mxa5d3xmhdkdanjq
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: propagate-exceptions
timestamp: Wed 2010-06-23 17:30:04 +0200
message:
  Move tests related to TestThreadWithException in test_test_server.
-------------- next part --------------
=== modified file 'bzrlib/tests/test_test_server.py'
--- a/bzrlib/tests/test_test_server.py	2010-06-07 16:55:30 +0000
+++ b/bzrlib/tests/test_test_server.py	2010-06-23 15:30:04 +0000
@@ -38,6 +38,46 @@
     return suite
 
 
+class TestThreadWithException(tests.TestCase):
+
+    def test_start_and_join_smoke_test(self):
+        def do_nothing():
+            pass
+
+        tt = test_server.ThreadWithException(target=do_nothing)
+        tt.start()
+        tt.join()
+
+    def test_exception_is_re_raised(self):
+        class MyException(Exception):
+            pass
+
+        def raise_my_exception():
+            raise MyException()
+
+        tt = test_server.ThreadWithException(target=raise_my_exception)
+        tt.start()
+        self.assertRaises(MyException, tt.join)
+
+    def test_join_when_no_exception(self):
+        resume = threading.Event()
+        class MyException(Exception):
+            pass
+
+        def raise_my_exception():
+            # Wait for the test to tell us to resume
+            resume.wait()
+            # Now we can raise
+            raise MyException()
+
+        tt = test_server.ThreadWithException(target=raise_my_exception)
+        tt.start()
+        tt.join(timeout=0)
+        self.assertIs(None, tt.exception)
+        resume.set()
+        self.assertRaises(MyException, tt.join)
+
+
 class TCPClient(object):
 
     def __init__(self):

=== modified file 'bzrlib/tests/test_transport.py'
--- a/bzrlib/tests/test_transport.py	2010-05-26 11:05:29 +0000
+++ b/bzrlib/tests/test_transport.py	2010-06-23 15:30:04 +0000
@@ -991,41 +991,3 @@
             t.join()
 
 
-class TestThreadWithException(tests.TestCase):
-
-    def test_start_and_join_smoke_test(self):
-        def do_nothing():
-            pass
-
-        tt = test_server.ThreadWithException(target=do_nothing)
-        tt.start()
-        tt.join()
-
-    def test_exception_is_re_raised(self):
-        class MyException(Exception):
-            pass
-
-        def raise_my_exception():
-            raise MyException()
-
-        tt = test_server.ThreadWithException(target=raise_my_exception)
-        tt.start()
-        self.assertRaises(MyException, tt.join)
-
-    def test_join_when_no_exception(self):
-        resume = threading.Event()
-        class MyException(Exception):
-            pass
-
-        def raise_my_exception():
-            # Wait for the test to tell us to resume
-            resume.wait()
-            # Now we can raise
-            raise MyException()
-
-        tt = test_server.ThreadWithException(target=raise_my_exception)
-        tt.start()
-        tt.join(timeout=0)
-        self.assertIs(None, tt.exception)
-        resume.set()
-        self.assertRaises(MyException, tt.join)



More information about the bazaar-commits mailing list