Skip to content

Fixes for flake8 master #4213

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 23, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions doc/en/example/py2py3/test_py2.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@

def test_exception_syntax():
try:
0/0
0 / 0
except ZeroDivisionError, e:
pass
assert e
2 changes: 1 addition & 1 deletion doc/en/example/py2py3/test_py3.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ def test_exception_syntax():
try:
0 / 0
except ZeroDivisionError as e:
pass
assert e
3 changes: 1 addition & 2 deletions src/_pytest/assertion/rewrite.py
Original file line number Diff line number Diff line change
Expand Up @@ -706,10 +706,9 @@ def run(self, mod):
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)

Expand Down
4 changes: 2 additions & 2 deletions src/_pytest/pathlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@RonnyPfannschmidt this one is subtle, and a new python3 behaviour:

exc = 'hi'
try:
    raise AssertionError('hello')
except Exception as exc:
    pass
print(exc)
$ python2 t.py
hello

$ python3 t.py 
Traceback (most recent call last):
  File "t.py", line 6, in <module>
    print(exc)
NameError: name 'exc' is not defined

from the docs

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fabulous work, thanks for digging

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So why was the assert e is not None below not causing a problem before? (since e should have been deleted)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, likely untested code - i.e. it returned instead of going there I assume.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Retry code that was never hit 🤷‍♂️

else:
consider_lock_dead_if_created_before = p.stat().st_mtime - lock_timeout
cleanup_numbered_dir(
Expand Down