Skip to content

Commit 366f3e5

Browse files
committed
Added another test to the AboutGenerators koan.
Demonstrates that next(generator) is exactly equivelant to generator.send(None) Added to both Python3 and Python2 koans.
1 parent ba6b812 commit 366f3e5

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

python 2/koans/about_generators.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,4 +123,11 @@ def test_generators_can_see_if_they_have_been_called_with_a_value(self):
123123
next(generator2)
124124
self.assertEqual(__, next(generator2))
125125

126+
def test_send_none_is_equivelant_to_next(self):
127+
generator = self.yield_tester()
128+
129+
next(generator)
130+
# 'next(generator)' is exactly equivelant to 'generator.send(None)'
131+
self.assertEqual(__, generator.send(None))
132+
126133

python 3/koans/about_generators.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,4 +126,11 @@ def test_generators_can_see_if_they_have_been_called_with_a_value(self):
126126
next(generator2)
127127
self.assertEqual(__, next(generator2))
128128

129-
129+
def test_send_none_is_equivelant_to_next(self):
130+
generator = self.yield_tester()
131+
132+
next(generator)
133+
# 'next(generator)' is exactly equivelant to 'generator.send(None)'
134+
self.assertEqual(__, generator.send(None))
135+
136+

0 commit comments

Comments
 (0)