Add a test for proper exception raising on bad start#25
Add a test for proper exception raising on bad start#25petertodd merged 1 commit intopetertodd:masterfrom
Conversation
There was a problem hiding this comment.
Seems you checked in a version of the test that you didn't actually try... this causes an uncaught ValueError.
Also, elsewhere I prefer to use the assertRaises with the with statement; more clear as to what exactly is going on.
Reminds me too: MsgSerializable should be raising a msg-specific exception class so serialization errors can be distinguished from unexpected ValueErrors. But I haven't actually had a chance to think through how that part of the API really should work.
There was a problem hiding this comment.
Oh, and if you're not familiar, here's what I'm talking about:
with self.assertRaises(SomeException):
do_something()
There was a problem hiding this comment.
Defintiely more readable, I'd forgotten you could use it as a context manager.
|
Ah, that's emabarssing. I chopped my |
0d8a973 to
6d11a20
Compare
6d11a20 Add a test for proper exception raising on bad start (Isaac Cook)
6d11a20 Add a test for proper exception raising on bad start (Isaac Cook) [ yapified by gitreformat (github/ghtdak) on Mon Nov 30 21:11:00 2015 ]
A test to confirm the fix on icook@bdfc18a#commitcomment-8588990. It appears the actual issue is passing a string instead of bytes object in Python 2.7. I read several docs that stated "bytes in Python 2.7 is simply an alias for str" but in this case it appears to not behave quite the same. In the test I wrote on Python 2.7 if I remove the "b" before my string it raises a formatting exception. With the b it works fine. This is likely a systemic issue, and I'm not sure of a clever way to catch it and provide helpful exceptions to users... It seems silly/wasteful/painful to try and wrap all format bytes calls with b2x.