88except ImportError :
99 import unittest
1010import sys
11- from six import b
1211import hypothesis .strategies as st
1312from hypothesis import given , settings
1413import pytest
@@ -33,44 +32,44 @@ class TestRemoveInteger(unittest.TestCase):
3332 # interpreted as negative, check if those errors are detected
3433 def test_non_minimal_encoding (self ):
3534 with self .assertRaises (UnexpectedDER ):
36- remove_integer (b ( "\x02 \x02 \x00 \x01 " ) )
35+ remove_integer (b"\x02 \x02 \x00 \x01 " )
3736
3837 def test_negative_with_high_bit_set (self ):
3938 with self .assertRaises (UnexpectedDER ):
40- remove_integer (b ( "\x02 \x01 \x80 " ) )
39+ remove_integer (b"\x02 \x01 \x80 " )
4140
4241 def test_minimal_with_high_bit_set (self ):
43- val , rem = remove_integer (b ( "\x02 \x02 \x00 \x80 " ) )
42+ val , rem = remove_integer (b"\x02 \x02 \x00 \x80 " )
4443
4544 self .assertEqual (val , 0x80 )
4645 self .assertEqual (rem , b"" )
4746
4847 def test_two_zero_bytes_with_high_bit_set (self ):
4948 with self .assertRaises (UnexpectedDER ):
50- remove_integer (b ( "\x02 \x03 \x00 \x00 \xff " ) )
49+ remove_integer (b"\x02 \x03 \x00 \x00 \xff " )
5150
5251 def test_zero_length_integer (self ):
5352 with self .assertRaises (UnexpectedDER ):
54- remove_integer (b ( "\x02 \x00 " ) )
53+ remove_integer (b"\x02 \x00 " )
5554
5655 def test_empty_string (self ):
5756 with self .assertRaises (UnexpectedDER ):
58- remove_integer (b ( "" ) )
57+ remove_integer (b"" )
5958
6059 def test_encoding_of_zero (self ):
61- val , rem = remove_integer (b ( "\x02 \x01 \x00 " ) )
60+ val , rem = remove_integer (b"\x02 \x01 \x00 " )
6261
6362 self .assertEqual (val , 0 )
6463 self .assertEqual (rem , b"" )
6564
6665 def test_encoding_of_127 (self ):
67- val , rem = remove_integer (b ( "\x02 \x01 \x7f " ) )
66+ val , rem = remove_integer (b"\x02 \x01 \x7f " )
6867
6968 self .assertEqual (val , 127 )
7069 self .assertEqual (rem , b"" )
7170
7271 def test_encoding_of_128 (self ):
73- val , rem = remove_integer (b ( "\x02 \x02 \x00 \x80 " ) )
72+ val , rem = remove_integer (b"\x02 \x02 \x00 \x80 " )
7473
7574 self .assertEqual (val , 128 )
7675 self .assertEqual (rem , b"" )
@@ -93,37 +92,37 @@ class TestReadLength(unittest.TestCase):
9392 # form and lengths above that encoded with minimal number of bytes
9493 # necessary
9594 def test_zero_length (self ):
96- self .assertEqual ((0 , 1 ), read_length (b ( "\x00 " ) ))
95+ self .assertEqual ((0 , 1 ), read_length (b"\x00 " ))
9796
9897 def test_two_byte_zero_length (self ):
9998 with self .assertRaises (UnexpectedDER ):
100- read_length (b ( "\x81 \x00 " ) )
99+ read_length (b"\x81 \x00 " )
101100
102101 def test_two_byte_small_length (self ):
103102 with self .assertRaises (UnexpectedDER ):
104- read_length (b ( "\x81 \x7f " ) )
103+ read_length (b"\x81 \x7f " )
105104
106105 def test_long_form_with_zero_length (self ):
107106 with self .assertRaises (UnexpectedDER ):
108- read_length (b ( "\x80 " ) )
107+ read_length (b"\x80 " )
109108
110109 def test_smallest_two_byte_length (self ):
111- self .assertEqual ((128 , 2 ), read_length (b ( "\x81 \x80 " ) ))
110+ self .assertEqual ((128 , 2 ), read_length (b"\x81 \x80 " ))
112111
113112 def test_zero_padded_length (self ):
114113 with self .assertRaises (UnexpectedDER ):
115- read_length (b ( "\x82 \x00 \x80 " ) )
114+ read_length (b"\x82 \x00 \x80 " )
116115
117116 def test_two_three_byte_length (self ):
118117 self .assertEqual ((256 , 3 ), read_length (b"\x82 \x01 \x00 " ))
119118
120119 def test_empty_string (self ):
121120 with self .assertRaises (UnexpectedDER ):
122- read_length (b ( "" ) )
121+ read_length (b"" )
123122
124123 def test_length_overflow (self ):
125124 with self .assertRaises (UnexpectedDER ):
126- read_length (b ( "\x83 \x01 \x00 " ) )
125+ read_length (b"\x83 \x01 \x00 " )
127126
128127
129128class TestEncodeBitstring (unittest .TestCase ):
@@ -270,10 +269,10 @@ def test_bytearray(self):
270269class TestEncodeOid (unittest .TestCase ):
271270 def test_pub_key_oid (self ):
272271 oid_ecPublicKey = encode_oid (1 , 2 , 840 , 10045 , 2 , 1 )
273- self .assertEqual (hexlify (oid_ecPublicKey ), b ( "06072a8648ce3d0201" ) )
272+ self .assertEqual (hexlify (oid_ecPublicKey ), b"06072a8648ce3d0201" )
274273
275274 def test_nist224p_oid (self ):
276- self .assertEqual (hexlify (NIST224p .encoded_oid ), b ( "06052b81040021" ) )
275+ self .assertEqual (hexlify (NIST224p .encoded_oid ), b"06052b81040021" )
277276
278277 def test_nist256p_oid (self ):
279278 self .assertEqual (
0 commit comments