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

use diff for multiline bytes #9482

Closed
RonnyPfannschmidt opened this issue Jan 5, 2022 · 2 comments
Closed

use diff for multiline bytes #9482

RonnyPfannschmidt opened this issue Jan 5, 2022 · 2 comments
Labels
topic: reporting related to terminal output and user-facing messages and errors type: enhancement new feature or API change, should be merged into features branch

Comments

@RonnyPfannschmidt
Copy link
Member

What's the problem this feature will solve?

unlike multiline stings, bytes get diffed as full value

Describe the solution you'd like

instead of

   def test_wheelinfo():
        wi = metadata.get_wheel_info()
        print(wi)
>       assert wi == WHEEL_DEFAULT_META
E       AssertionError: assert b'Wheel-Versi... py3-none-any' == b'Wheel-Versi... py3-none-any'
E         At index 79 diff: b'3' != b'2'
E         Use -v to get the full diff

i want to see sometihing like

______________________________________________ test_wheelinfo ______________________________________________

    def test_wheelinfo():
        wi = metadata.get_wheel_info()
        print(wi)
>       assert wi.decode() == WHEEL_DEFAULT_META
E       AssertionError: assert 'Wheel-Versio... py3-none-any' == 'Wheel-Versio... py3-none-any'
E         Skipping 69 identical leading characters in diff, use -v to show
E           ue
E         - Tag: py27-none-any
E           Tag: py3-none-any
@RonnyPfannschmidt RonnyPfannschmidt added type: enhancement new feature or API change, should be merged into features branch topic: reporting related to terminal output and user-facing messages and errors labels Jan 5, 2022
@The-Compiler
Copy link
Member

Also see #5199 - I tend to agree with what @nicoddemus has said there:

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.

Personally I'd prefer if Python's bytes-repr would not show ascii data at all (since for "real" binary data, it's confusing). I feel like we should resist the temptation to interpret even more into data we know nothing about.

@RonnyPfannschmidt
Copy link
Member Author

true, maybe a pytest plugin with more fun bytes diffs needs to be made

closing as not fit for core

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: reporting related to terminal output and user-facing messages and errors type: enhancement new feature or API change, should be merged into features branch
Projects
None yet
Development

No branches or pull requests

2 participants