-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
pdb prompt unusable if doctests ran first (macOS and Python 3) #985
Comments
for testing purposes i'd suggest to write s small script using python pexpect that then can be used to test against different versions an potentially for bisecting the responsible change do you have a rough set of known good/bad releases |
I rolled back to pytest 2.6.x and 2.7.0, but the issue remained. I'll try some older versions. I bet there's something else in my environment causing the issue but I can't imagine what. I'll try even older versions. Good idea. |
I can reproduce the issue back to pytest 2.4 or py 1.4.24 on Python 2.7 or Python 3, but only on OS X. I've been unable to reproduce the issue on Ubuntu. |
FWIW I can't reproduce the problem on Windows either. 😕 |
Given that I adopted Mac in May 2015 and that the issue appears to only affect Mac, even on Pytest 2.4 which was released in 2013, I believe the issue is not a recent regression, as I suspected, but simply a broken behavior on macOS (formerly OS X). |
i see, as such most of us are unable to test/experiment :/ |
Would someone on the pytest team point me to the code where doctests are invoked and where pdb is invoked? From there, I'll try to devise a minimal test that replicates the failure. |
@jaraco could you please try running pytest's own test suite first? The current tests might detect the problem already. |
The tests all passed on Python 2.6, but on 3.5, there are many failures. I don't see anything in those results that appears to me to relate to doctests or pdb prompts. I do see a lot of skips in the pdb tests, but I can't see which skip message(s) are relevant. Aha, so running just the tests in |
Those are the ones we want to run, actually. 😁 Are you running using |
I installed pexpect, but now the tests xfail.
|
If I remove that xfail:
The tests now hang partway in.
|
Hmm that's interesting, so it seems to reproduce the issue already then? |
I don't think so. |
I added some debug output to determine where the test is hanging.
And it appears to be hanging on the
|
According to the docs, "this [call] will block forever if the child has unread output and has terminated." Maybe that's what's happening. |
After applying #2024, the failure is revealed in this test run:
|
Okay, now in the issue-985 branch, there's an additional test demonstrating the failure in another mode where doctests being present and run affect the PDB prompt, even when the doctests pass. |
All tests, including the additional one added above, pass on Python 2.7 with |
I'm going to break on this for now, but I welcome further contribution. |
This issue persists for me. I repeatedly find myself editing the pytest.ini and commenting out the |
I'm experiencing this too, I'm looking into it. Two libraries both playing around with sys.stdout and pdb.set_trace behind the scenes => recipe for disaster |
@brianmaissy can you try running with |
Yeah I'll try that |
Yeah that solves it! |
I'm having trouble following the exact flow, but my best guess is that this is what's happening:
I found a fix that works, but I'm far from confident that it's the correct fix. If we add the line: Sample implementation: And maybe we need to turn it back on afterwards? |
@nicoddemus what do you think? Alternatively, if this isn't worth the time (and only happens on mac for some reason) we can just call it a known issue and xfail the test on mac |
@brianmaissy I think this is the way to go, at least until someone can dedicate some time to nail this down. |
k, ill open a PR |
Consider this simple test:
Create a virtualenv on Python 3.4.3, install pytest 2.7.2 and py 1.4.30 and run py.test:
Everything's fine - the pdb prompt is displayed and works as expected. However, invoke pytest with
--doctest-modules
, and the story is different.Although the code stops in the right place, the pdb prompt does not appear. Keystrokes appear to be ignored. Only sending an EOF (
^d
) allows the test to fail and pytest to exit.This issue seems to have emerged recently, though I can't imagine what could be causing it. I've tested in a virtualenv, tried upgrading and downgrading pytest, and tried older setuptools versions.
What's the next step to troubleshoot?
The text was updated successfully, but these errors were encountered: