-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Running with --pdb causes import failure #1810
Comments
I'd like to work on this as a way to get acclimated to the pytest code base. If the idea is to move the import to the top of the file, wouldn't something in test_capture.py need to be changed? |
note that in pytest 3.x the module is i think that move would be sufficient |
@RonnyPfannschmidt when moving the import in debugging.py to the top of the file, the python3 tests fail during test_logging_initialized_in_test in test_capture.py.
The full assertion error report can be found here: https://bpaste.net/show/d0e649b5c7bd Looks like the test fails due to fnmatch not finding a match for hello432. I'm not sure how the import and this test relate, any advice would be appreciated. |
it seems that doctest imports logging, thus breaking the expectation of the test |
So I guess moving @r-owen if you are running out of file-handles, I'm guessing you will fail sometime soon anyway so just moving doctest to the top probably won't fix your problem. |
I think @r-owen's point is that pytest fails before it can report what the real error is because it can't load the correct exception. If the exception was pre-loaded then it would be able to report the actual error. |
One alternative would be to protect that import: try:
from doctest import UnexpectedException
except:
UnexpectedException = RuntimeError then at least we could properly throw something even if the type of the exception is wrong. I don't know if there is code higher up that is trying to catch |
@timj is correct: if the test fails due to running out of available open files the the reporting of the test must not try to open any more files, thus must not import any additional modules. Otherwise the reported error is confusing. |
I'm running py.test with --pdb and when something goes wrong I get an unwanted failure here:
in
_pytest/pdb.py
which is done only executed after the problem has been detected. The problem is that the error that is triggering pdb is running out of file handles, and that apparently makes the import fail.I suggest moving that import to near the top of the file, with other imports, so
UnexpectedException
is guaranteed to be available.I suspect this will be hard to unit test, since you'll have to explicitly run out of file handles.
This is using Python 2.7 on OS X 10.11 with pytest 2.9.2
The text was updated successfully, but these errors were encountered: