273
273
self.assertThat(synchronous(return_args), Provides(ISynchronous))
276
class TestSynchronousDecoratorSychronously(MAASTestCase):
277
"""Test `synchronous` outside of the reactor thread."""
279
def test__raises_TypeError_when_call_returns_Deferred(self):
281
def deferSomething(*args, **kwargs):
284
a, b = factory.make_name("a"), factory.make_name("b")
285
error = self.assertRaises(TypeError, deferSomething, a, b=b)
286
self.assertThat(str(error), Equals(
287
"Synchronous call returned a Deferred: %s(%r, b=%r)"
288
% (deferSomething.__qualname__, a, b)))
290
def test__raises_TypeError_when_callable_returns_Deferred(self):
292
def __call__(self, *args, **kwargs):
295
something = Something()
296
a, b = factory.make_name("a"), factory.make_name("b")
297
error = self.assertRaises(TypeError, synchronous(something), a, b=b)
298
self.assertThat(str(error), Equals(
299
"Synchronous call returned a Deferred: %s(%r, b=%r)"
300
% (Something.__qualname__, a, b)))
276
303
class TestRetries(MAASTestCase):