From: Brian Warner Date: Mon, 23 Feb 2009 21:43:12 +0000 (-0700) Subject: tests: stop using setUpClass/tearDownClass, since they've been deprecated in Twisted... X-Git-Url: https://git.rkrishnan.org/?a=commitdiff_plain;h=f35c659b2f7e4c9d1c8bc3e7cf1e2daac9d724b6;p=tahoe-lafs%2Ftahoe-lafs.git tests: stop using setUpClass/tearDownClass, since they've been deprecated in Twisted-8.2.0 --- diff --git a/src/allmydata/test/common_util.py b/src/allmydata/test/common_util.py index 27d6b434..0b7b919d 100644 --- a/src/allmydata/test/common_util.py +++ b/src/allmydata/test/common_util.py @@ -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() diff --git a/src/allmydata/test/test_node.py b/src/allmydata/test/test_node.py index 1542402b..ef9b4510 100644 --- a/src/allmydata/test/test_node.py +++ b/src/allmydata/test/test_node.py @@ -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) diff --git a/src/allmydata/test/test_runner.py b/src/allmydata/test/test_runner.py index 9ced2a71..7de528d4 100644 --- a/src/allmydata/test/test_runner.py +++ b/src/allmydata/test/test_runner.py @@ -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