Пример #1
0
 def test_bytewise_invalid(self, limit):
     exception = ValueError if isinstance(limit, int) else TypeError
     with raises(exception):
         bytewise(b'python', limit=limit)
Пример #2
0
 def test_bytewise_show_len(self):
     operand = bytes.fromhex(' '.join((f'{i:02X}' for i in range(256))))
     expected = '00 01 02 03 04 05 06 07 .. FF'
     assert bytewise(operand, limit=10, show_len=False) == expected
     assert bytewise(operand, limit=10) == expected + ' (256 bytes)'
Пример #3
0
 def test_bytewise_big(self):
     expected = ' '.join(''.join(choices('0123456789ABCDEF', k=2))
                         for _ in range(2**16 + 1))
     operand = bytes.fromhex(expected)
     assert bytewise(operand) == expected
Пример #4
0
 def test_bytewise_limit(self, data_bytewise_limit):
     operand, expected, limit = data_bytewise_limit
     assert bytewise(operand, sep='-', limit=limit,
                     show_len=False) == expected
Пример #5
0
 def test_bytewise_sep(self, data_bytewise, sep):
     operand, expected = data_bytewise
     expected = expected.replace(' ', sep)
     assert bytewise(operand, sep=sep) == expected
Пример #6
0
 def test_bytewise(self, data_bytewise):
     operand, expected = data_bytewise
     assert bytewise(operand) == expected