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
Assertion error truncates byte strings #5199
Comments
Thanks @nickwilliams-eventbrite for the report! Closing as a duplicate of #5192 |
@nicoddemus, after further experimentation, this is definitely not a duplicate of #5192. It's actually caused by the fact that On a simpler test case, I get the following when
However, if
As you can see, it's clearly not related to #5192, because the verbosity does not affect the issue. So what remains to be determined is:
|
@nickwilliams-eventbrite thanks for the follow up, you are correct. I've edited the title of the issue to reflect the underlying cause. I'm not sure what to do here; your byte strings are actually text in this example, but we cannot assume this in general; for example the byte strings might be an image, in which case trying to display any part of it in the assertion message will only result in garbage. I think it is reasonable to expect that users do the decoding themselves, as they know best what are the underlying contents of the byte string. |
Custom assertion messages should not get shortened via `saferepr`. Via #125. Fixes pytest-dev#5199.
Custom assertion messages should not get shortened via `saferepr`. Via #125. Fixes pytest-dev#5199.
Custom assertion messages should not get shortened via `saferepr`. Closes #125. Ref: pytest-dev#5199.
Closing this under the same reasoning as #9482; at least for core Pytest we think it's important to 'refuse the temptation to guess'. This would be a good feature for a plugin though! |
a detailed description of the bug or suggestion
Even when using arguments
-vvvv --full-trace
, an explicit assertion error is truncated. This is different from comparisons/diffs. Those are not truncated. But when an explicit assertion error message is provided, its contents are truncated. Example:Where
self.get
returns a Python RequestsResponse
object. The point of this assertion line is that, if the status code is not correct, the entire response content is dumped so that the error code(s) and message(s) is the JSON response can be viewed. However, this is the result, even with full verbosity:The response content, in this case, was ~5000 bytes, but only ~250 are displayed, with an ellipse in the middle. With anything
-vv
or greater, the entire assertion message should be displayed.output of
pip list
from the virtual environment you are usingpytest and operating system versions
Ubuntu 16.04
minimal example if possible
See above.
The text was updated successfully, but these errors were encountered: