tests: stop using setUpClass/tearDownClass, since they've been deprecated in Twisted-8.2.0

This commit is contained in:
Brian Warner 2009-02-23 14:43:12 -07:00
parent bc91689f8e
commit f35c659b2f
3 changed files with 11 additions and 6 deletions

@ -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()

@ -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)

@ -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