Skip to content

Commit

Permalink
Merge pull request #4153 from asottile/syntax_warning_filename
Browse files Browse the repository at this point in the history
Display the filename when encountering `SyntaxWarning`.
  • Loading branch information
asottile authored Oct 15, 2018
2 parents 8abf30a + 2e42d93 commit 093e19a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions changelog/4152.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Display the filename when encountering ``SyntaxWarning``.
2 changes: 1 addition & 1 deletion src/_pytest/assertion/rewrite.py
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ def _rewrite_test(config, fn):
finally:
del state._indecode
try:
tree = ast.parse(source)
tree = ast.parse(source, filename=fn.strpath)
except SyntaxError:
# Let this pop up again in the real import.
state.trace("failed to parse: %r" % (fn,))
Expand Down

0 comments on commit 093e19a

Please sign in to comment.