Skip to content
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

ptw fails silently on startup if there is a syntax error #73

Closed
markscottwright opened this issue Jul 10, 2017 · 5 comments
Closed

ptw fails silently on startup if there is a syntax error #73

markscottwright opened this issue Jul 10, 2017 · 5 comments
Labels

Comments

@markscottwright
Copy link

markscottwright commented Jul 10, 2017

With the following unit test file:

# file test_syntax.py
print("hello"

ptw will fail silently.

D:\temp\t>type test_syntax.py
print("hello"

D:\temp\t>ptw

D:\temp\t>

If I fix the syntax error, I can start ptw. If I introduce a syntax error later (after starting ptw, while it is still running), I get the expected SyntaxError exception:

Running: py.test
============================= test session starts =============================
platform win32 -- Python 3.5.3, pytest-3.1.3, py-1.4.34, pluggy-0.4.0
rootdir: D:\temp\t, inifile:
collected 0 items / 1 errors

=================================== ERRORS ====================================
_______________________ ERROR collecting test_syntax.py _______________________
d:\tools\python35\lib\site-packages\_pytest\python.py:408: in _importtestmodule
    mod = self.fspath.pyimport(ensuresyspath=importmode)
d:\tools\python35\lib\site-packages\py\_path\local.py:662: in pyimport
    __import__(modname)
E     File "D:\temp\t\test_syntax.py", line 2
E
E       ^
E   SyntaxError: unexpected EOF while parsing
!!!!!!!!!!!!!!!!!!! Interrupted: 1 errors during collection !!!!!!!!!!!!!!!!!!!
=========================== 1 error in 0.20 seconds ===========================
@blueyed
Copy link
Collaborator

blueyed commented Jul 10, 2017

Related previous fix: #45

Some code part to look at:

def _collect_config(pytest_args, silent=True):
if silent:
try:
with silence():
return _run_pytest_collect(pytest_args)

@blueyed blueyed added the bug label Jul 10, 2017
@blueyed
Copy link
Collaborator

blueyed commented Sep 5, 2017

@markscottwright
Just tried to reproduce this on master, but it seems to work?!
Might be related also to fixes/changes in pytest.

@blueyed
Copy link
Collaborator

blueyed commented Sep 5, 2017

Found this when looking into it: pytest-dev/pytest#2753.

@grantbachman
Copy link

Has there been any movement on this? I've been bitten by this bug a few times and it's confounding when you encounter it because it isn't apparent anything is even wrong. If it helps at all, I've tested PR #90 locally and it seems to fix the issue for me.

@joeyespo
Copy link
Owner

Just released v4.2.0 which includes a fix for this. Thanks for opening the issue, @markscottwright!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants