equal_to behaves badly with bytes #52

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

Projects

None yet

2 participants

@oconnor663

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
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 notifications@github.com
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

@oconnor663 oconnor663 referenced this issue in keis/base58 Apr 8, 2015
Merged

test round trips #3

@offbyone offbyone added a commit that referenced this issue Apr 10, 2015
@offbyone offbyone Add tests for #52 77b996e
@offbyone
Member

Fixed & released as 1.8.3

@offbyone offbyone closed this Apr 10, 2015
@offbyone offbyone added a commit that referenced this issue Apr 11, 2015
@offbyone offbyone Merge branch 'release-1.8' into mainline
Include fixes from #52
d64f09f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment