3d6932581601 — Greg Malcolm 13 years ago
From icmurry, github: Added test demonstrating that calling send on a generator with a non-None argument is illegal.

    Demonstrates a TypeError is raised.
2 files changed, 17 insertions(+), 1 deletions(-)

M python 2/koans/about_generators.py
M python 3/koans/about_generators.py
M python 2/koans/about_generators.py +9 -1
@@ 104,7 104,15 @@ class AboutGenerators(Koan):
         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):

          
M python 3/koans/about_generators.py +8 -0
@@ 107,6 107,14 @@ class AboutGenerators(Koan):
         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])
                 
     # ------------------------------------------------------------------