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

equal_to behaves badly with bytes #52

Closed
oconnor663 opened this issue Apr 8, 2015 · 2 comments
Closed

equal_to behaves badly with bytes #52

oconnor663 opened this issue Apr 8, 2015 · 2 comments

Comments

@oconnor663
Copy link

assert_that(b'foo', equal_to(b'bar')) should fail cleanly, but instead it hits a TypeError inside hamcrest.

Python 3.4.3 (default, Mar 25 2015, 17:13:50) 
[GCC 4.9.2 20150304 (prerelease)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from hamcrest import *
>>> assert_that(b'foo', equal_to(b'bar'))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/jacko/.local/lib/python3.4/site-packages/hamcrest/core/assert_that.py", line 43, in assert_that
    _assert_match(actual=arg1, matcher=arg2, reason=arg3)
  File "/home/jacko/.local/lib/python3.4/site-packages/hamcrest/core/assert_that.py", line 53, in _assert_match
    .append_description_of(matcher)  \
  File "/home/jacko/.local/lib/python3.4/site-packages/hamcrest/core/base_description.py", line 25, in append_description_of
    value.describe_to(self)
  File "/home/jacko/.local/lib/python3.4/site-packages/hamcrest/core/core/isequal.py", line 21, in describe_to
    description.append_description_of(self.object)
  File "/home/jacko/.local/lib/python3.4/site-packages/hamcrest/core/base_description.py", line 29, in append_description_of
    self.append_string_in_python_syntax(value)
  File "/home/jacko/.local/lib/python3.4/site-packages/hamcrest/core/base_description.py", line 78, in append_string_in_python_syntax
    self.append(character_in_python_syntax(ch))
  File "/home/jacko/.local/lib/python3.4/site-packages/hamcrest/core/string_description.py", line 34, in append
    self.out += string
TypeError: Can't convert 'int' object to str implicitly
@offbyone
Copy link
Member

offbyone commented Apr 8, 2015

Damn, that's ugly. I'll see what I can do to resolve that. Thanks.


Chris
offbyone on GitHub, offby1 on twitter

On Wed, Apr 8, 2015 at 12:00 PM, oconnor663 [email protected]
wrote:

assert_that(b'foo', equal_to(b'bar')) should fail cleanly, but instead it hits a TypeError inside hamcrest.

Python 3.4.3 (default, Mar 25 2015, 17:13:50) 
[GCC 4.9.2 20150304 (prerelease)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from hamcrest import *
>>> assert_that(b'foo', equal_to(b'bar'))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/jacko/.local/lib/python3.4/site-packages/hamcrest/core/assert_that.py", line 43, in assert_that
    _assert_match(actual=arg1, matcher=arg2, reason=arg3)
  File "/home/jacko/.local/lib/python3.4/site-packages/hamcrest/core/assert_that.py", line 53, in _assert_match
    .append_description_of(matcher)  \
  File "/home/jacko/.local/lib/python3.4/site-packages/hamcrest/core/base_description.py", line 25, in append_description_of
    value.describe_to(self)
  File "/home/jacko/.local/lib/python3.4/site-packages/hamcrest/core/core/isequal.py", line 21, in describe_to
    description.append_description_of(self.object)
  File "/home/jacko/.local/lib/python3.4/site-packages/hamcrest/core/base_description.py", line 29, in append_description_of
    self.append_string_in_python_syntax(value)
  File "/home/jacko/.local/lib/python3.4/site-packages/hamcrest/core/base_description.py", line 78, in append_string_in_python_syntax
    self.append(character_in_python_syntax(ch))
  File "/home/jacko/.local/lib/python3.4/site-packages/hamcrest/core/string_description.py", line 34, in append
    self.out += string
TypeError: Can't convert 'int' object to str implicitly

Reply to this email directly or view it on GitHub:
#52

@offbyone
Copy link
Member

Fixed & released as 1.8.3

offbyone added a commit that referenced this issue Apr 11, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants