From 22c3c6010fc614e380d4d6473ff2e8d76acafc2f Mon Sep 17 00:00:00 2001 From: Chris Withers Date: Thu, 20 Apr 2023 10:46:53 +0100 Subject: [PATCH] Add coverage for timeout waiting on a call --- tests/test_hook.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/test_hook.py b/tests/test_hook.py index e4dcbcd..acd0b67 100644 --- a/tests/test_hook.py +++ b/tests/test_hook.py @@ -1,4 +1,5 @@ from testfixtures import ShouldRaise, compare +from twisted.internet.defer import inlineCallbacks, TimeoutError from twisted.trial.unittest import TestCase from carly import hook, cleanup @@ -27,3 +28,11 @@ def testUnconsumedCalls(self): def testUnconsumedstr(self): compare(str(UnconsumedCalls({})), expected='\n{}') + + @inlineCallbacks + def testTimeout(self): + hook(Sample, 'method') + self.addCleanup(cleanup) + obj = Sample() + with ShouldRaise(TimeoutError): + yield obj.method.called(timeout=0.01)