Debian Codegraph @

hypothesis-python/tests/ghostwriter/recorded/base64_magic.txt

raw
1 # This test code was written by the `hypothesis.extra.ghostwriter` module
2 # and is provided under the Creative Commons Zero public domain dedication.
3
4 import base64
5 from hypothesis import given, strategies as st
6
7 # TODO: replace st.nothing() with appropriate strategies
8
9
10 @given(
11 adobe=st.booleans(),
12 b=st.nothing(),
13 foldspaces=st.booleans(),
14 ignorechars=st.just(b" \t\n\r\x0b"),
15 pad=st.booleans(),
16 wrapcol=st.just(0),
17 )
18 def test_roundtrip_a85encode_a85decode(adobe, b, foldspaces, ignorechars, pad, wrapcol):
19 value0 = base64.a85encode(
20 b=b, foldspaces=foldspaces, wrapcol=wrapcol, pad=pad, adobe=adobe
21 )
22 value1 = base64.a85decode(
23 b=value0, foldspaces=foldspaces, adobe=adobe, ignorechars=ignorechars
24 )
25 assert b == value1, (b, value1)
26
27
28 @given(casefold=st.booleans(), s=st.nothing())
29 def test_roundtrip_b16encode_b16decode(casefold, s):
30 value0 = base64.b16encode(s=s)
31 value1 = base64.b16decode(s=value0, casefold=casefold)
32 assert s == value1, (s, value1)
33
34
35 @given(casefold=st.booleans(), map01=st.none(), s=st.nothing())
36 def test_roundtrip_b32encode_b32decode(casefold, map01, s):
37 value0 = base64.b32encode(s=s)
38 value1 = base64.b32decode(s=value0, casefold=casefold, map01=map01)
39 assert s == value1, (s, value1)
40
41
42 @given(altchars=st.none(), s=st.nothing(), validate=st.booleans())
43 def test_roundtrip_b64encode_b64decode(altchars, s, validate):
44 value0 = base64.b64encode(s=s, altchars=altchars)
45 value1 = base64.b64decode(s=value0, altchars=altchars, validate=validate)
46 assert s == value1, (s, value1)
47
48
49 @given(b=st.nothing(), pad=st.booleans())
50 def test_roundtrip_b85encode_b85decode(b, pad):
51 value0 = base64.b85encode(b=b, pad=pad)
52 value1 = base64.b85decode(b=value0)
53 assert b == value1, (b, value1)
54
55
56 @given(input=st.nothing(), output=st.nothing())
57 def test_roundtrip_encode_decode(input, output):
58 value0 = base64.encode(input=input, output=output)
59 value1 = base64.decode(input=value0, output=output)
60 assert input == value1, (input, value1)
61
62
63 @given(s=st.nothing())
64 def test_roundtrip_encodebytes_decodebytes(s):
65 value0 = base64.encodebytes(s=s)
66 value1 = base64.decodebytes(s=value0)
67 assert s == value1, (s, value1)
68
69
70 @given(s=st.nothing())
71 def test_roundtrip_standard_b64encode_standard_b64decode(s):
72 value0 = base64.standard_b64encode(s=s)
73 value1 = base64.standard_b64decode(s=value0)
74 assert s == value1, (s, value1)
75
76
77 @given(s=st.nothing())
78 def test_roundtrip_urlsafe_b64encode_urlsafe_b64decode(s):
79 value0 = base64.urlsafe_b64encode(s=s)
80 value1 = base64.urlsafe_b64decode(s=value0)
81 assert s == value1, (s, value1)