Пример #1
0
    def test_false(self):
        from aiopyramid.helpers import is_generator

        def _sample():
            return "plain old function"

        self.assertFalse(is_generator(_sample))
Пример #2
0
    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)))
Пример #3
0
    def test_regular_yield(self):
        from aiopyramid.helpers import is_generator

        def _sample():
            yield 1
            yield 2

        self.assertTrue(is_generator(_sample))
Пример #4
0
    def test_coroutine(self):
        from aiopyramid.helpers import is_generator

        @asyncio.coroutine
        def _sample():
            return 5

        self.assertTrue(is_generator(_sample))
Пример #5
0
    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))