From 6096aeca538be79ceea02268e56e93d1c50433ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Bartoszkiewicz?= Date: Mon, 11 Jul 2011 11:57:47 +0200 Subject: [PATCH] Fix a typo in assertion rewriting. --- _pytest/assertion/rewrite.py | 2 +- testing/test_assertrewrite.py | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/_pytest/assertion/rewrite.py b/_pytest/assertion/rewrite.py index 751f73a1e..a6eb832f5 100644 --- a/_pytest/assertion/rewrite.py +++ b/_pytest/assertion/rewrite.py @@ -421,7 +421,7 @@ class AssertionRewriter(ast.NodeVisitor): if chain: where = [] if len(chain) > 1: - cond = ast.Boolop(ast.And(), chain) + cond = ast.BoolOp(ast.And(), list(chain)) else: cond = chain[0] self.statements.append(ast.If(cond, where, [])) diff --git a/testing/test_assertrewrite.py b/testing/test_assertrewrite.py index 62a256db5..0cdd81b00 100644 --- a/testing/test_assertrewrite.py +++ b/testing/test_assertrewrite.py @@ -138,6 +138,12 @@ class TestAssertionRewrite: assert f or g getmsg(f, must_pass=True) + def test_long_chain(self): + def f(): + f = g = h = lambda: True + assert f() and g() and h() + getmsg(f, must_pass=True) + def test_short_circut_evaluation(self): def f(): assert True or explode