Skip to content

Commit 60fbd7c

Browse files
Fix tests.
1 parent 0df9a40 commit 60fbd7c

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

Lib/test/test_base64.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ def test_decodebytes(self):
7878
@hypothesis.given(payload=hypothesis.strategies.binary())
7979
@hypothesis.example(b'abcdefghijklmnopqrstuvwxyz')
8080
def test_bytes_encode_decode_round_trip(self, payload):
81+
base64 = self.module
8182
encoded = base64.encodebytes(payload)
8283
decoded = base64.decodebytes(encoded)
8384
self.assertEqual(payload, decoded)
@@ -115,6 +116,7 @@ def test_decode(self):
115116
@hypothesis.given(payload=hypothesis.strategies.binary())
116117
@hypothesis.example(b'abcdefghijklmnopqrstuvwxyz')
117118
def test_legacy_encode_decode_round_trip(self, payload):
119+
base64 = self.module
118120
from io import BytesIO
119121
payload_file_r = BytesIO(payload)
120122
encoded_file_w = BytesIO()
@@ -271,6 +273,7 @@ def test_b64decode(self):
271273

272274
def test_b64decode_altchars(self):
273275
# Test with arbitrary alternative characters
276+
base64 = self.module
274277
eq = self.assertEqual
275278
res = b'\xd3V\xbeo\xf7\x1d'
276279
for altchars in b'*$', b'+/', b'/+', b'+_', b'-+', b'-/', b'/_':
@@ -342,6 +345,7 @@ def _altchars_strategy():
342345
@hypothesis.example(b'abcdefghijklmnopqrstuvwxyz', b"_-", True)
343346
@hypothesis.example(b'abcdefghijklmnopqrstuvwxyz', b"_-", False)
344347
def test_b64_encode_decode_round_trip(self, payload, altchars, validate):
348+
base64 = self.module
345349
encoded = base64.b64encode(payload, altchars=altchars)
346350
decoded = base64.b64decode(encoded, altchars=altchars,
347351
validate=validate)
@@ -350,13 +354,15 @@ def test_b64_encode_decode_round_trip(self, payload, altchars, validate):
350354
@hypothesis.given(payload=hypothesis.strategies.binary())
351355
@hypothesis.example(b'abcdefghijklmnopqrstuvwxyz')
352356
def test_standard_b64_encode_decode_round_trip(self, payload):
357+
base64 = self.module
353358
encoded = base64.standard_b64encode(payload)
354359
decoded = base64.standard_b64decode(encoded)
355360
self.assertEqual(payload, decoded)
356361

357362
@hypothesis.given(payload=hypothesis.strategies.binary())
358363
@hypothesis.example(b'abcdefghijklmnopqrstuvwxyz')
359364
def test_urlsafe_b64_encode_decode_round_trip(self, payload):
365+
base64 = self.module
360366
encoded = base64.urlsafe_b64encode(payload)
361367
decoded = base64.urlsafe_b64decode(encoded)
362368
self.assertEqual(payload, decoded)
@@ -419,6 +425,7 @@ def test_b32decode_casefold(self):
419425

420426
def test_b32decode_map01(self):
421427
# Mapping zero and one
428+
base64 = self.module
422429
eq = self.assertEqual
423430
res_L = b'b\xdd\xad\xf3\xbe'
424431
res_I = b'b\x1d\xad\xf3\xbe'
@@ -471,6 +478,7 @@ def test_b32decode_error(self):
471478
@hypothesis.example(b'abcdefghijklmnopqrstuvwxyz', True, None)
472479
@hypothesis.example(b'abcdefghijklmnopqrstuvwxyz', False, None)
473480
def test_b32_encode_decode_round_trip(self, payload, casefold, map01):
481+
base64 = self.module
474482
encoded = base64.b32encode(payload)
475483
decoded = base64.b32decode(encoded, casefold=casefold, map01=map01)
476484
self.assertEqual(payload, decoded)
@@ -555,6 +563,7 @@ def test_b32hexdecode_error(self):
555563
@hypothesis.example(b'abcdefghijklmnopqrstuvwxyz', True)
556564
@hypothesis.example(b'abcdefghijklmnopqrstuvwxyz', False)
557565
def test_b32_hexencode_decode_round_trip(self, payload, casefold):
566+
base64 = self.module
558567
encoded = base64.b32hexencode(payload)
559568
decoded = base64.b32hexdecode(encoded, casefold=casefold)
560569
self.assertEqual(payload, decoded)
@@ -603,6 +612,7 @@ def test_b16decode(self):
603612
@hypothesis.example(b'abcdefghijklmnopqrstuvwxyz', True)
604613
@hypothesis.example(b'abcdefghijklmnopqrstuvwxyz', False)
605614
def test_b16_encode_decode_round_trip(self, payload, casefold):
615+
base64 = self.module
606616
endoded = base64.b16encode(payload)
607617
decoded = base64.b16decode(endoded, casefold=casefold)
608618
self.assertEqual(payload, decoded)
@@ -971,6 +981,7 @@ def add_padding(self, payload):
971981
def test_a85_encode_decode_round_trip(
972982
self, payload, foldspaces, wrapcol, pad, adobe
973983
):
984+
base64 = self.module
974985
encoded = base64.a85encode(
975986
payload, foldspaces=foldspaces, wrapcol=wrapcol,
976987
pad=pad, adobe=adobe,
@@ -997,6 +1008,7 @@ def test_a85_encode_decode_round_trip(
9971008
@hypothesis.example(b'abcdefghijklmnopqrstuvwxyz', True)
9981009
@hypothesis.example(b'abcdefghijklmnopqrstuvwxyz', False)
9991010
def test_b85_encode_decode_round_trip(self, payload, pad):
1011+
base64 = self.module
10001012
encoded = base64.b85encode(payload, pad=pad)
10011013
if pad:
10021014
payload = self.add_padding(payload)

0 commit comments

Comments
 (0)