File tree 1 file changed +16
-0
lines changed
1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -1350,6 +1350,22 @@ def __init__(self, value):
1350
1350
self .assertEqual (i , 1 )
1351
1351
self .assertEqual (getattr (i , 'foo' , 'none' ), 'bar' )
1352
1352
1353
+ class ValidBytes :
1354
+ def __bytes__ (self ):
1355
+ return b'\x01 '
1356
+ class InvalidBytes :
1357
+ def __bytes__ (self ):
1358
+ return 'abc'
1359
+ class MissingBytes : ...
1360
+ class RaisingBytes :
1361
+ def __bytes__ (self ):
1362
+ 1 / 0
1363
+
1364
+ self .assertEqual (int .from_bytes (ValidBytes ()), 1 )
1365
+ self .assertRaises (TypeError , int .from_bytes , InvalidBytes ())
1366
+ self .assertRaises (TypeError , int .from_bytes , MissingBytes ())
1367
+ self .assertRaises (ZeroDivisionError , int .from_bytes , RaisingBytes ())
1368
+
1353
1369
def test_access_to_nonexistent_digit_0 (self ):
1354
1370
# http://bugs.python.org/issue14630: A bug in _PyLong_Copy meant that
1355
1371
# ob_digit[0] was being incorrectly accessed for instances of a
You can’t perform that action at this time.
0 commit comments