def test_generator_with_broken_name_support(self): def fn(): yield 42 provider = jeni.GeneratorProvider(fn, support_name=True) provider.init() self.assertEqual(42, provider.get()) self.assertRaises(RuntimeError, provider.get, name='name')
def test_unyielding_generator(self): def fn(work=False): if work: yield 'foo' self.assertEqual(['foo'], list(fn(work=True))) provider = jeni.GeneratorProvider(fn) self.assertRaises(RuntimeError, provider.init)
def test_init_no_error(self): def fn(): yield 42 provider = jeni.GeneratorProvider(fn) provider.init() provider.get() provider.close()
def test_init_error(self): def fn(): yield provider = jeni.GeneratorProvider(fn) self.assertRaises(RuntimeError, provider.get) self.assertRaises(RuntimeError, provider.close)
def test_generator_which_keeps_yielding(self): def fn(): yield 'one' yield 'two' provider = jeni.GeneratorProvider(fn) self.assertRaises(RuntimeError, provider.close)
def test_generator(self): def fn(): yield 42 provider = jeni.GeneratorProvider(fn) provider.init() self.assertEqual(42, provider.get()) self.assertEqual(42, provider.get()) self.assertRaises(TypeError, provider.get, name='name')