limit test time to 2 minutes, then consider it a failure and log what was running
This commit is contained in:
parent
7371c30064
commit
27cc61d45e
2 changed files with 10 additions and 0 deletions
|
@ -84,6 +84,7 @@ class AsyncioTestCase(unittest.TestCase):
|
|||
# https://bugs.python.org/issue32972
|
||||
|
||||
LOOP_SLOW_CALLBACK_DURATION = 0.2
|
||||
TIMEOUT = 120.0
|
||||
|
||||
maxDiff = None
|
||||
|
||||
|
@ -137,6 +138,8 @@ class AsyncioTestCase(unittest.TestCase):
|
|||
with outcome.testPartExecutor(self, isTest=True):
|
||||
maybe_coroutine = testMethod()
|
||||
if asyncio.iscoroutine(maybe_coroutine):
|
||||
if self.TIMEOUT:
|
||||
self.loop.call_later(self.TIMEOUT, self.cancel)
|
||||
self.loop.run_until_complete(maybe_coroutine)
|
||||
outcome.expecting_failure = False
|
||||
with outcome.testPartExecutor(self):
|
||||
|
@ -189,6 +192,12 @@ class AsyncioTestCase(unittest.TestCase):
|
|||
if asyncio.iscoroutine(maybe_coroutine):
|
||||
self.loop.run_until_complete(maybe_coroutine)
|
||||
|
||||
def cancel(self):
|
||||
for task in asyncio.all_tasks(self.loop):
|
||||
if not task.done():
|
||||
task.print_stack()
|
||||
task.cancel()
|
||||
|
||||
|
||||
class AdvanceTimeTestCase(AsyncioTestCase):
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@ from lbry.extras.daemon.storage import SQLiteStorage
|
|||
|
||||
|
||||
class TestNodePingQueueDiscover(AsyncioTestCase):
|
||||
TIMEOUT = None # not supported as it advances time
|
||||
async def test_ping_queue_discover(self):
|
||||
loop = asyncio.get_event_loop()
|
||||
loop.set_debug(False)
|
||||
|
|
Loading…
Reference in a new issue