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
assert failure inside doctest doesn't prettyprint #7
Comments
Original comment by holger krekel (BitBucket: hpk42, GitHub: hpk42): actually you may install the fix with pip install -i http://pypi.testrun.org -U pytest (py.test --version should show 2.0.1.dev3). Please open a new issue for the more general suggestion. I am not sure i understand it. Normally, when test source code fails and you see a traceback, you can scroll up a bit and see which line in the test function started it. This was obfuscated in the doctest reporting but should be fixed now. If an issue remains please open a new issue and provide an example if you can. cheers, holger |
Original comment by BitBucket: wtanksleyjr, GitHub: wtanksleyjr: I confirm that one of my suggestions in this bug is fixed. The test case I attached to my original report still says there's something wrong, since assert still doesn't prettyprint its results -- but at least the correct line number is deduced. |
Original comment by BitBucket: wtanksleyjr, GitHub: wtanksleyjr: I'd like it if assert worked inside a doctest, but am I wasting my time? I can see that it might be very hard to make that work. Doctest is very brittle, since it compares textual representations. Assert is robust, since it can use any method. py.test makes assert as informative as doctest... So the combination would be perfect. But perhaps this is impossible -- doctest is different from py.test's assert, and perhaps they're incompatible, since doctest is supposed to catch and interpret assertions. |
Before: > FAILED foo/test.py::test_bar - Failed: Database access not allowed, … After: > FAILED foo/test.py::test_bar - Database access not allowed, …
fix: avoid errors when filename is too long
Originally reported by: BitBucket: wtanksleyjr, GitHub: wtanksleyjr
Asserts inside doctests don't parse correctly; they instead produce an error that points to the wrong line. It looks like the backtrace is getting confused.
It may be possible to fix this specific error by finding a bug in our doctest code; but it may also be possible to handle the general case where the backtracking information doesn't lead into the test code. When that happens, it would be ideal to show an error message that points to the last line of test code run, even if the location isn't in the backtrace.
I've attached doc.py to demonstrate the assert problem.
The text was updated successfully, but these errors were encountered: