Skip to content

Commit

Permalink
Migrate the nested generator test.
Browse files Browse the repository at this point in the history
  • Loading branch information
stephan-hof committed Nov 29, 2016
1 parent a88fd0c commit 588c5f7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 43 deletions.
43 changes: 0 additions & 43 deletions src/RestrictedPython/tests/before_and_after24.py

This file was deleted.

12 changes: 12 additions & 0 deletions tests/test_transformer.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,9 @@ def set_comp(it):
def generator(it):
return (a + a for a in it)
def nested_generator(it1, it2):
return (a+b for a in it1 if a > 0 for b in it2)
"""


Expand Down Expand Up @@ -295,6 +298,15 @@ def test_transformer__RestrictingNodeTransformer__guard_iter(compile, mocker):
_getiter_.assert_called_once_with(it)
_getiter_.reset_mock()

ret = glb['nested_generator']((0, 1, 2), (1, 2))
assert isinstance(ret, types.GeneratorType)
assert list(ret) == [2, 3, 3, 4]
_getiter_.assert_has_calls([
mocker.call((0, 1, 2)),
mocker.call((1, 2)),
mocker.call((1, 2))])
_getiter_.reset_mock()


ITERATORS_WITH_UNPACK_SEQUENCE = """
def for_loop(it):
Expand Down

0 comments on commit 588c5f7

Please sign in to comment.