Display the filename when encountering `SyntaxWarning`.
```console $ cd t && rm -rf __pycache__ && pytest t.py -q -c /dev/null; cd .. . [100%] =============================== warnings summary =============================== <unknown>:2: DeprecationWarning: invalid escape sequence \. -- Docs: https://docs.pytest.org/en/latest/warnings.html 1 passed, 1 warnings in 0.01 seconds ``` ```console $ cd t && rm -rf __pycache__ && pytest t.py -q -c /dev/null; cd .. . [100%] =============================== warnings summary =============================== /tmp/pytest/t/t.py:2: DeprecationWarning: invalid escape sequence \. '\.wat' -- Docs: https://docs.pytest.org/en/latest/warnings.html 1 passed, 1 warnings in 0.01 seconds ```
This commit is contained in:
parent
6258248865
commit
2e42d937dc
|
@ -0,0 +1 @@
|
|||
Display the filename when encountering ``SyntaxWarning``.
|
|
@ -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,))
|
||||
|
|
Loading…
Reference in New Issue