mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-01-21 03:55:27 +00:00
Get rid of the sys.exit monkey-patch
It's just an exception. Let it get logged and then check after.
This commit is contained in:
parent
a04a915628
commit
faf8da82dd
@ -516,12 +516,6 @@ class CLI(CLITestMixin, unittest.TestCase):
|
|||||||
raise exc
|
raise exc
|
||||||
|
|
||||||
stderr = StringIO()
|
stderr = StringIO()
|
||||||
ns = Namespace()
|
|
||||||
|
|
||||||
ns.sys_exit_called = False
|
|
||||||
def call_sys_exit(exitcode):
|
|
||||||
ns.sys_exit_called = True
|
|
||||||
self.failUnlessEqual(exitcode, 1)
|
|
||||||
|
|
||||||
def fake_react(f):
|
def fake_react(f):
|
||||||
reactor = Mock()
|
reactor = Mock()
|
||||||
@ -530,8 +524,7 @@ class CLI(CLITestMixin, unittest.TestCase):
|
|||||||
# it's safe to drop it on the floor.
|
# it's safe to drop it on the floor.
|
||||||
f(reactor)
|
f(reactor)
|
||||||
|
|
||||||
patcher = MonkeyPatcher((sys, 'exit', call_sys_exit),
|
patcher = MonkeyPatcher((task, 'react', fake_react),
|
||||||
(task, 'react', fake_react),
|
|
||||||
)
|
)
|
||||||
patcher.runWithPatches(
|
patcher.runWithPatches(
|
||||||
lambda: runner.run(
|
lambda: runner.run(
|
||||||
@ -541,8 +534,9 @@ class CLI(CLITestMixin, unittest.TestCase):
|
|||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
self.failUnless(ns.sys_exit_called)
|
|
||||||
self.failUnlessIn(str(exc), stderr.getvalue())
|
self.failUnlessIn(str(exc), stderr.getvalue())
|
||||||
|
[exit_exc] = self.flushLoggedErrors(SystemExit)
|
||||||
|
self.assertEqual(1, exit_exc.value.code)
|
||||||
|
|
||||||
|
|
||||||
class Help(unittest.TestCase):
|
class Help(unittest.TestCase):
|
||||||
|
Loading…
Reference in New Issue
Block a user