-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtests.py
29 lines (19 loc) · 921 Bytes
/
tests.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import unittest
from importlib.util import spec_from_loader, module_from_spec
from importlib.machinery import SourceFileLoader
spec = spec_from_loader("base64url", SourceFileLoader("base64url", "./base64url"))
base64url = module_from_spec(spec)
spec.loader.exec_module(base64url)
class TestBase64URL(unittest.TestCase):
def test_decode(self):
self.assertEqual(base64url.decode("SGVsbG8gd29ybGQ="), b"Hello world")
def test_decode_no_padding(self):
self.assertEqual(base64url.decode("SGVsbG8gd29ybGQ"), b"Hello world")
def test_decode_empty_string(self):
self.assertEqual(base64url.decode(""), b"")
def test_encode(self):
self.assertEqual(base64url.encode(b"Hello world"), "SGVsbG8gd29ybGQ=")
def test_encode_trimmed(self):
self.assertEqual(base64url.encode(b"Hello world", trim=True), "SGVsbG8gd29ybGQ")
if __name__ == "__main__":
unittest.main()