mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-01-21 03:55:27 +00:00
fix tests by overriding/patching reactor.stop in tests
This commit is contained in:
parent
423208f391
commit
0607b7331f
@ -37,6 +37,7 @@ class Util(unittest.TestCase):
|
||||
with patch('twisted.internet.reactor') as r:
|
||||
def call(fn, *args, **kw):
|
||||
fn()
|
||||
r.stop = lambda: None
|
||||
r.callWhenRunning = call
|
||||
service = plug.makeService(None)
|
||||
service.parent = Mock()
|
||||
@ -52,6 +53,7 @@ class Util(unittest.TestCase):
|
||||
def call(fn, *args, **kw):
|
||||
fn()
|
||||
r.callWhenRunning = call
|
||||
r.stop = lambda: None
|
||||
service = plug.makeService(None)
|
||||
service.parent = Mock()
|
||||
with self.assertRaises(ValueError) as ctx:
|
||||
@ -68,6 +70,7 @@ class Util(unittest.TestCase):
|
||||
with patch('twisted.internet.reactor') as r:
|
||||
def call(fn, *args, **kw):
|
||||
fn()
|
||||
r.stop = lambda: None
|
||||
r.callWhenRunning = call
|
||||
service = plug.makeService(None)
|
||||
service.parent = Mock()
|
||||
@ -97,6 +100,7 @@ class RunDaemonizeTests(unittest.TestCase):
|
||||
self._working = os.path.abspath('.')
|
||||
d = super(RunDaemonizeTests, self).setUp()
|
||||
self._reactor = patch('twisted.internet.reactor')
|
||||
self._reactor.stop = lambda: None
|
||||
self._twistd = patch('allmydata.scripts.tahoe_daemonize.twistd')
|
||||
self.node_dir = self.mktemp()
|
||||
os.mkdir(self.node_dir)
|
||||
|
@ -218,7 +218,11 @@ class RunTests(unittest.TestCase):
|
||||
os.mkdir(self.node_dir)
|
||||
return d
|
||||
|
||||
def test_run_invalid_config(self):
|
||||
@patch('twisted.internet.reactor')
|
||||
def test_run_invalid_config(self, reactor):
|
||||
def cwr(fn, *args, **kw):
|
||||
fn()
|
||||
reactor.callWhenRunning = cwr
|
||||
|
||||
with open(os.path.join(self.node_dir, "client.tac"), "w") as f:
|
||||
f.write('test')
|
||||
|
Loading…
Reference in New Issue
Block a user