diff --git a/src/_pytest/assertion/rewrite.py b/src/_pytest/assertion/rewrite.py index 0a3713285..0e988a8f4 100644 --- a/src/_pytest/assertion/rewrite.py +++ b/src/_pytest/assertion/rewrite.py @@ -991,13 +991,13 @@ warn_explicit( def visit_all(self, call): """Special rewrite for the builtin all function, see #5602""" - if not isinstance(call.args[0], ast.GeneratorExp): + if not isinstance(call.args[0], (ast.GeneratorExp, ast.ListComp)): return gen_exp = call.args[0] assertion_module = ast.Module( body=[ast.Assert(test=gen_exp.elt, lineno=1, msg="", col_offset=1)] ) - AssertionRewriter(None, None).run(assertion_module) + AssertionRewriter(module_path=None, config=None).run(assertion_module) for_loop = ast.For( iter=gen_exp.generators[0].iter, target=gen_exp.generators[0].target, diff --git a/testing/test_assertrewrite.py b/testing/test_assertrewrite.py index 8add65e0a..c453fe57d 100644 --- a/testing/test_assertrewrite.py +++ b/testing/test_assertrewrite.py @@ -677,7 +677,7 @@ class TestAssertionRewrite(object): assert "UnicodeDecodeError" not in msg assert "UnicodeEncodeError" not in msg - def test_generator(self, testdir): + def test_unroll_generator(self, testdir): testdir.makepyfile( """ def check_even(num): @@ -692,7 +692,7 @@ class TestAssertionRewrite(object): result = testdir.runpytest() result.stdout.fnmatch_lines(["*assert False*", "*where False = check_even(1)*"]) - def test_list_comprehension(self, testdir): + def test_unroll_list_comprehension(self, testdir): testdir.makepyfile( """ def check_even(num):