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

Confusing assertion rewriting message with byte strings #5260

Closed
blueyed opened this issue May 14, 2019 · 3 comments

Comments

Projects
None yet
2 participants
@blueyed
Copy link
Contributor

commented May 14, 2019

The comparison with assertion rewriting for byte strings is confusing:

    def test_b():
>       assert b"" == b"42"
E       AssertionError: assert b'' == b'42'
E         Right contains more items, first extra item: 52
E         Full diff:
E         - b''
E         + b'42'
E         ?   ++

52 is the ASCII ordinal of "4" here.

It became clear to me when using another example:

    def test_b():
>       assert b"" == b"1"
E       AssertionError: assert b'' == b'1'
E         Right contains more items, first extra item: 49
E         Full diff:
E         - b''
E         + b'1'
E         ?   +

Not sure what should/could be done here.

@asottile

This comment has been minimized.

Copy link
Member

commented May 14, 2019

hmmm yes, this ~kinda makes sense as bytes objects are sequences of integers -- we should maybe just omit the "contains more items" messaging for bytes objects?

blueyed added a commit to blueyed/pytest that referenced this issue May 15, 2019

@blueyed

This comment has been minimized.

Copy link
Contributor Author

commented May 15, 2019

Turns out that it was meant to handle bytes already, but only not for Python 3.
#5267

@blueyed

This comment has been minimized.

Copy link
Contributor Author

commented May 15, 2019

~kinda makes sense as bytes objects are sequences of integers

Yeah, but it was just confusing at first.
Strings are also a sequence of chars, but handled differently.

I've seen another issue recently where it was said that bytes are not decoded on purpose, but I think it is fine for when there are bytes on both sides?!

blueyed added a commit to blueyed/pytest that referenced this issue May 15, 2019

nicoddemus added a commit to nicoddemus/pytest that referenced this issue Jun 25, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.