]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
tests: stop using setUpClass/tearDownClass, since they've been deprecated in Twisted...
authorBrian Warner <warner@lothar.com>
Mon, 23 Feb 2009 21:43:12 +0000 (14:43 -0700)
committerBrian Warner <warner@lothar.com>
Mon, 23 Feb 2009 21:43:12 +0000 (14:43 -0700)
src/allmydata/test/common_util.py
src/allmydata/test/test_node.py
src/allmydata/test/test_runner.py

index 27d6b434ba4f49e9a21c01e70838e47757ed0e1f..0b7b919d8f0982dfaf5896ff91f975edb4e021ba 100644 (file)
@@ -28,10 +28,11 @@ def flip_one_bit(s, offset=0, size=None):
 class SignalMixin:
     # This class is necessary for any code which wants to use Processes
     # outside the usual reactor.run() environment. It is copied from
-    # Twisted's twisted.test.test_process
+    # Twisted's twisted.test.test_process . Note that Twisted-8.2.0 uses
+    # something rather different.
     sigchldHandler = None
 
-    def setUpClass(self):
+    def setUp(self):
         # make sure SIGCHLD handler is installed, as it should be on
         # reactor.run(). problem is reactor may not have been run when this
         # test runs.
@@ -39,7 +40,7 @@ class SignalMixin:
             self.sigchldHandler = signal.signal(signal.SIGCHLD,
                                                 reactor._handleSigchld)
 
-    def tearDownClass(self):
+    def tearDown(self):
         if self.sigchldHandler:
             signal.signal(signal.SIGCHLD, self.sigchldHandler)
 
@@ -79,6 +80,7 @@ class TestMixin(SignalMixin):
             to without access to real randomness and real time.time from the
             code under test
         """
+        SignalMixin.setUp(self)
         self.repeatable = repeatable
         if self.repeatable:
             import repeatable_random
@@ -89,6 +91,7 @@ class TestMixin(SignalMixin):
             self.teststarttime = time.time()
 
     def tearDown(self):
+        SignalMixin.tearDown(self)
         if self.repeatable:
             import repeatable_random
             repeatable_random.restore_non_repeatability()
index 1542402bde0ea014ce7f07da5d135a7e326576cb..ef9b4510eba72df47e308c9694ecd1c7dbf4ca96 100644 (file)
@@ -18,12 +18,14 @@ class TestNode(Node):
     CERTFILE='DEFAULT_CERTFILE_BLANK'
     PORTNUMFILE='DEFAULT_PORTNUMFILE_BLANK'
 
-class TestCase(unittest.TestCase, testutil.SignalMixin):
+class TestCase(testutil.SignalMixin, unittest.TestCase):
     def setUp(self):
+        testutil.SignalMixin.setUp(self)
         self.parent = LoggingMultiService()
         self.parent.startService()
     def tearDown(self):
         log.msg("%s.tearDown" % self.__class__.__name__)
+        testutil.SignalMixin.tearDown(self)
         d = defer.succeed(None)
         d.addCallback(lambda res: self.parent.stopService())
         d.addCallback(flushEventualQueue)
index 9ced2a71d9d623d11fb63f1e742a9c34f2f69efe..7de528d47522866c55d4dd321726fe311475acee 100644 (file)
@@ -19,7 +19,7 @@ class SkipOnCygwinMixin:
         if "cygwin" in sys.platform.lower():
             raise unittest.SkipTest("We don't know how to make this test work on cygwin: spawnProcess seems to hang forever. We don't know if 'bin/tahoe start' can be run on cygwin.")
 
-class TheRightCode(unittest.TestCase, common_util.SignalMixin,
+class TheRightCode(common_util.SignalMixin, unittest.TestCase,
                    SkipOnCygwinMixin):
     def test_path(self):
         self.skip_on_cygwin()
@@ -207,7 +207,7 @@ class CreateNode(unittest.TestCase):
                               run_by_human=False)
 
 
-class RunNode(unittest.TestCase, pollmixin.PollMixin, common_util.SignalMixin,
+class RunNode(common_util.SignalMixin, unittest.TestCase, pollmixin.PollMixin,
               SkipOnCygwinMixin):
     # exercise "tahoe start", for both introducer, client node, and
     # key-generator, by spawning "tahoe start" as a subprocess. This doesn't