Fix assertion rewriting involving Starred + side-effects

This commit is contained in:
Anthony Sottile
2018-11-17 10:41:44 -08:00
parent 4c9cde74ab
commit 690a63b921
3 changed files with 16 additions and 1 deletions

View File

@@ -413,6 +413,19 @@ class TestAssertionRewrite(object):
)
testdir.runpytest().assert_outcomes(passed=1)
@pytest.mark.skipif("sys.version_info < (3,5)")
def test_starred_with_side_effect(self, testdir):
"""See #4412"""
testdir.makepyfile(
"""\
def test():
f = lambda x: x
x = iter([1, 2, 3])
assert 2 * next(x) == f(*[next(x)])
"""
)
testdir.runpytest().assert_outcomes(passed=1)
def test_call(self):
def g(a=42, *args, **kwargs):
return False