From cb39bd065165c6bafb78e30f56b0fca82df5a74d Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Mon, 22 Oct 2018 08:49:31 -0700 Subject: [PATCH] Fixes for flake8 master --- doc/en/example/py2py3/test_py2.py | 5 ++--- doc/en/example/py2py3/test_py3.py | 2 +- src/_pytest/assertion/rewrite.py | 3 +-- src/_pytest/pathlib.py | 4 ++-- 4 files changed, 6 insertions(+), 8 deletions(-) diff --git a/doc/en/example/py2py3/test_py2.py b/doc/en/example/py2py3/test_py2.py index 664acf178..1f665086e 100644 --- a/doc/en/example/py2py3/test_py2.py +++ b/doc/en/example/py2py3/test_py2.py @@ -1,6 +1,5 @@ - def test_exception_syntax(): try: - 0/0 + 0 / 0 except ZeroDivisionError, e: - pass + assert e diff --git a/doc/en/example/py2py3/test_py3.py b/doc/en/example/py2py3/test_py3.py index baf0ffbd8..d95702a53 100644 --- a/doc/en/example/py2py3/test_py3.py +++ b/doc/en/example/py2py3/test_py3.py @@ -2,4 +2,4 @@ def test_exception_syntax(): try: 0 / 0 except ZeroDivisionError as e: - pass + assert e diff --git a/src/_pytest/assertion/rewrite.py b/src/_pytest/assertion/rewrite.py index 5e76563d9..9b3daf9b4 100644 --- a/src/_pytest/assertion/rewrite.py +++ b/src/_pytest/assertion/rewrite.py @@ -706,10 +706,9 @@ class AssertionRewriter(ast.NodeVisitor): setattr(node, name, new) elif ( isinstance(field, ast.AST) - and # Don't recurse into expressions as they can't contain # asserts. - not isinstance(field, ast.expr) + and not isinstance(field, ast.expr) ): nodes.append(field) diff --git a/src/_pytest/pathlib.py b/src/_pytest/pathlib.py index 081fce904..bf46cbf70 100644 --- a/src/_pytest/pathlib.py +++ b/src/_pytest/pathlib.py @@ -245,8 +245,8 @@ def make_numbered_dir_with_cleanup(root, prefix, keep, lock_timeout): p = make_numbered_dir(root, prefix) lock_path = create_cleanup_lock(p) register_cleanup_lock_removal(lock_path) - except Exception as e: - pass + except Exception as exc: + e = exc else: consider_lock_dead_if_created_before = p.stat().st_mtime - lock_timeout cleanup_numbered_dir(