diff --git a/src/allmydata/test/cli_node_api.py b/src/allmydata/test/cli_node_api.py index 903148131..e4a96537f 100644 --- a/src/allmydata/test/cli_node_api.py +++ b/src/allmydata/test/cli_node_api.py @@ -26,7 +26,12 @@ from twisted.internet.defer import ( succeed, ) -from allmydata.client import _Client +from ..client import ( + _Client, +) +from ..scripts.tahoe_stop import ( + COULD_NOT_STOP, +) class Expect(Protocol): def __init__(self): @@ -134,6 +139,20 @@ class CLINodeAPI(object): # the test fails), the client should still terminate. self.exit_trigger_file.touch() + def cleanup(self): + stopping = stop_and_wait(tahoe) + stopping.addErrback( + # Let it fail because the process has already exited. + lambda err: ( + err.trap(ProcessTerminated) + and self.assertEqual( + err.value.exitCode, + COULD_NOT_STOP, + ) + ) + ) + return stopping + class _WaitForEnd(ProcessProtocol): def __init__(self, ended): diff --git a/src/allmydata/test/test_runner.py b/src/allmydata/test/test_runner.py index 99ae78e95..0166eb0bb 100644 --- a/src/allmydata/test/test_runner.py +++ b/src/allmydata/test/test_runner.py @@ -41,9 +41,6 @@ from ._twisted_9607 import ( from ..util.eliotutil import ( inline_callbacks, ) -from ..scripts.tahoe_stop import ( - COULD_NOT_STOP, -) timeout = 240 @@ -614,18 +611,7 @@ class RunNode(common_util.SignalMixin, unittest.TestCase, pollmixin.PollMixin, tahoe = CLINodeAPI(reactor, FilePath(c1)) # Set this up right now so we don't forget later. - self.addCleanup( - lambda: stop_and_wait(tahoe).addErrback( - # Let it fail because the process has already exited. - lambda err: ( - err.trap(ProcessTerminated) - and self.assertEqual( - err.value.exitCode, - COULD_NOT_STOP, - ) - ) - ) - ) + self.addCleanup(tahoe.cleanup) out, err, rc_or_sig = yield self.run_bintahoe([ "--quiet", "create-node", "--basedir", c1,