forked from LBRYCommunity/lbry-sdk
added timeout of async operations to integration test setup/teardown
This commit is contained in:
parent
d19e07d661
commit
dca7977051
1 changed files with 8 additions and 2 deletions
|
@ -132,17 +132,18 @@ class AsyncioTestCase(unittest.TestCase):
|
||||||
|
|
||||||
with outcome.testPartExecutor(self):
|
with outcome.testPartExecutor(self):
|
||||||
self.setUp()
|
self.setUp()
|
||||||
|
self.addTimeout()
|
||||||
self.loop.run_until_complete(self.asyncSetUp())
|
self.loop.run_until_complete(self.asyncSetUp())
|
||||||
if outcome.success:
|
if outcome.success:
|
||||||
outcome.expecting_failure = expecting_failure
|
outcome.expecting_failure = expecting_failure
|
||||||
with outcome.testPartExecutor(self, isTest=True):
|
with outcome.testPartExecutor(self, isTest=True):
|
||||||
maybe_coroutine = testMethod()
|
maybe_coroutine = testMethod()
|
||||||
if asyncio.iscoroutine(maybe_coroutine):
|
if asyncio.iscoroutine(maybe_coroutine):
|
||||||
if self.TIMEOUT:
|
self.addTimeout()
|
||||||
self.loop.call_later(self.TIMEOUT, self.cancel)
|
|
||||||
self.loop.run_until_complete(maybe_coroutine)
|
self.loop.run_until_complete(maybe_coroutine)
|
||||||
outcome.expecting_failure = False
|
outcome.expecting_failure = False
|
||||||
with outcome.testPartExecutor(self):
|
with outcome.testPartExecutor(self):
|
||||||
|
self.addTimeout()
|
||||||
self.loop.run_until_complete(self.asyncTearDown())
|
self.loop.run_until_complete(self.asyncTearDown())
|
||||||
self.tearDown()
|
self.tearDown()
|
||||||
|
|
||||||
|
@ -190,6 +191,7 @@ class AsyncioTestCase(unittest.TestCase):
|
||||||
with outcome.testPartExecutor(self):
|
with outcome.testPartExecutor(self):
|
||||||
maybe_coroutine = function(*args, **kwargs)
|
maybe_coroutine = function(*args, **kwargs)
|
||||||
if asyncio.iscoroutine(maybe_coroutine):
|
if asyncio.iscoroutine(maybe_coroutine):
|
||||||
|
self.addTimeout()
|
||||||
self.loop.run_until_complete(maybe_coroutine)
|
self.loop.run_until_complete(maybe_coroutine)
|
||||||
|
|
||||||
def cancel(self):
|
def cancel(self):
|
||||||
|
@ -198,6 +200,10 @@ class AsyncioTestCase(unittest.TestCase):
|
||||||
task.print_stack()
|
task.print_stack()
|
||||||
task.cancel()
|
task.cancel()
|
||||||
|
|
||||||
|
def addTimeout(self):
|
||||||
|
if self.TIMEOUT:
|
||||||
|
self.loop.call_later(self.TIMEOUT, self.cancel)
|
||||||
|
|
||||||
|
|
||||||
class AdvanceTimeTestCase(AsyncioTestCase):
|
class AdvanceTimeTestCase(AsyncioTestCase):
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue