def test_false(self): from aiopyramid.helpers import is_generator def _sample(): return "plain old function" self.assertFalse(is_generator(_sample))
def test_conversion(self): from aiopyramid.helpers import synchronize from aiopyramid.helpers import is_generator syncer = synchronize(strict=True) self.assertRaises(ConfigurationError, syncer, self._simple) self.assertFalse(is_generator(syncer(self._sample)))
def test_regular_yield(self): from aiopyramid.helpers import is_generator def _sample(): yield 1 yield 2 self.assertTrue(is_generator(_sample))
def test_coroutine(self): from aiopyramid.helpers import is_generator @asyncio.coroutine def _sample(): return 5 self.assertTrue(is_generator(_sample))
def test_yield_from(self): from aiopyramid.helpers import is_generator def _placeholder(): yield 6 return 7 def _sample(): yield from _placeholder self.assertTrue(is_generator(_sample))