Skip to content

Commit 093e19a

Browse files
authored
Merge pull request #4153 from asottile/syntax_warning_filename
Display the filename when encountering `SyntaxWarning`.
2 parents 8abf30a + 2e42d93 commit 093e19a

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

changelog/4152.bugfix.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Display the filename when encountering ``SyntaxWarning``.

src/_pytest/assertion/rewrite.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ def _rewrite_test(config, fn):
398398
finally:
399399
del state._indecode
400400
try:
401-
tree = ast.parse(source)
401+
tree = ast.parse(source, filename=fn.strpath)
402402
except SyntaxError:
403403
# Let this pop up again in the real import.
404404
state.trace("failed to parse: %r" % (fn,))

0 commit comments

Comments
 (0)