Skip to content

Commit

Permalink
Added test demonstrating that calling send on a generator with a non-…
Browse files Browse the repository at this point in the history
…None argument is illegal.

Demonstrates a TypeError is raised.
  • Loading branch information
icmurray committed Feb 4, 2011
1 parent ff1981a commit bfdebc5
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
10 changes: 9 additions & 1 deletion python 2/koans/about_generators.py
Expand Up @@ -104,7 +104,15 @@ def test_generators_can_take_coroutines(self):
next(generator)

self.assertEqual(__, generator.send(1 + 2))


def test_before_sending_a_value_to_a_generator_next_must_be_called(self):
generator = self.generator_with_coroutine()

try:
generator.send(1+2)
except TypeError as ex:
self.assertMatch(__, ex[0])

# ------------------------------------------------------------------

def yield_tester(self):
Expand Down
8 changes: 8 additions & 0 deletions python 3/koans/about_generators.py
Expand Up @@ -107,6 +107,14 @@ def test_generators_can_take_coroutines(self):
next(generator)

self.assertEqual(__, generator.send(1 + 2))

def test_before_sending_a_value_to_a_generator_next_must_be_called(self):
generator = self.generator_with_coroutine()

try:
generator.send(1+2)
except TypeError as ex:
self.assertMatch(__, ex[0])

# ------------------------------------------------------------------

Expand Down

0 comments on commit bfdebc5

Please sign in to comment.