File tree Expand file tree Collapse file tree 1 file changed +16
-0
lines changed
Expand file tree Collapse file tree 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):
13501350 self .assertEqual (i , 1 )
13511351 self .assertEqual (getattr (i , 'foo' , 'none' ), 'bar' )
13521352
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+
13531369 def test_access_to_nonexistent_digit_0 (self ):
13541370 # http://bugs.python.org/issue14630: A bug in _PyLong_Copy meant that
13551371 # ob_digit[0] was being incorrectly accessed for instances of a
You can’t perform that action at this time.
0 commit comments