This commit is contained in:
Benjamin Peterson 2012-12-19 15:28:46 -06:00
commit 7643c92cdd
3 changed files with 37 additions and 5 deletions

View file

@ -715,6 +715,12 @@ class BytesTest(BaseBytesTest):
def __bytes__(self):
return None
self.assertRaises(TypeError, bytes, A())
class A:
def __bytes__(self):
return b'a'
def __index__(self):
return 42
self.assertEqual(bytes(A()), b'a')
# Test PyBytes_FromFormat()
def test_from_format(self):