PNG  IHDR* pHYs+ IDATx]n#; cdLb Ǚ[at¤_:uP}>!Usă cag޿ ֵNu`ݼTâabO7uL&y^wFٝA"l[|ŲHLN밪4*sG3|Dv}?+y߉{OuOAt4Jj.u]Gz*҉sP'VQKbA1u\`& Af;HWj hsO;ogTu uj7S3/QzUr&wS`M$X_L7r2;aE+ώ%vikDA:dR+%KzƉo>eOth$z%: :{WwaQ:wz%4foɹE[9<]#ERINƻv溂E%P1i01 |Jvҗ&{b?9g=^wζXn/lK::90KwrюO\!ջ3uzuGv^;騢wq<Iatv09:tt~hEG`v;3@MNZD.1]L:{ծI3`L(÷ba")Y.iljCɄae#I"1 `3*Bdz>j<fU40⨬%O$3cGt]j%Fߠ_twJ;ABU8vP3uEԑwQ V:h%))LfraqX-ۿX]v-\9I gl8tzX ]ecm)-cgʒ#Uw=Wlێn(0hPP/ӨtQ“&J35 $=]r1{tLuǮ*i0_;NƝ8;-vݏr8+U-kruȕYr0RnC]*ެ(M:]gE;{]tg(#ZJ9y>utRDRMdr9㪩̞zֹb<ģ&wzJM"iI( .ꮅX)Qw:9,i좜\Ԛi7&N0:asϓc];=ΗOӣ APqz93 y $)A*kVHZwBƺnWNaby>XMN*45~ղM6Nvm;A=jֲ.~1}(9`KJ/V F9[=`~[;sRuk]rєT!)iQO)Y$V ی ۤmzWz5IM Zb )ˆC`6 rRa}qNmUfDsWuˤV{ Pݝ'=Kֳbg,UҘVz2ﴻnjNgBb{? ߮tcsͻQuxVCIY۠:(V뺕 ٥2;t`@Fo{Z9`;]wMzU~%UA蛚dI vGq\r82iu +St`cR.6U/M9IENDB` REDROOM
PHP 5.6.40
Preview: b64_test.py Size: 2.20 KB
/proc/thread-self/root/lib/python3.6/site-packages/josepy/b64_test.py

"""Tests for josepy.b64."""
import unittest


# https://en.wikipedia.org/wiki/Base64#Examples
B64_PADDING_EXAMPLES = {
    b'any carnal pleasure.': (b'YW55IGNhcm5hbCBwbGVhc3VyZS4', b'='),
    b'any carnal pleasure': (b'YW55IGNhcm5hbCBwbGVhc3VyZQ', b'=='),
    b'any carnal pleasur': (b'YW55IGNhcm5hbCBwbGVhc3Vy', b''),
    b'any carnal pleasu': (b'YW55IGNhcm5hbCBwbGVhc3U', b'='),
    b'any carnal pleas': (b'YW55IGNhcm5hbCBwbGVhcw', b'=='),
}


B64_URL_UNSAFE_EXAMPLES = {
    bytes((251, 239)): b'--8',
    bytes((255,)) * 2: b'__8',
}


class B64EncodeTest(unittest.TestCase):
    """Tests for josepy.b64.b64encode."""

    @classmethod
    def _call(cls, data):
        from josepy.b64 import b64encode
        return b64encode(data)

    def test_empty(self):
        self.assertEqual(self._call(b''), b'')

    def test_unsafe_url(self):
        for text, b64 in B64_URL_UNSAFE_EXAMPLES.items():
            self.assertEqual(self._call(text), b64)

    def test_different_paddings(self):
        for text, (b64, _) in B64_PADDING_EXAMPLES.items():
            self.assertEqual(self._call(text), b64)

    def test_unicode_fails_with_type_error(self):
        self.assertRaises(TypeError, self._call, u'some unicode')


class B64DecodeTest(unittest.TestCase):
    """Tests for josepy.b64.b64decode."""

    @classmethod
    def _call(cls, data):
        from josepy.b64 import b64decode
        return b64decode(data)

    def test_unsafe_url(self):
        for text, b64 in B64_URL_UNSAFE_EXAMPLES.items():
            self.assertEqual(self._call(b64), text)

    def test_input_without_padding(self):
        for text, (b64, _) in B64_PADDING_EXAMPLES.items():
            self.assertEqual(self._call(b64), text)

    def test_input_with_padding(self):
        for text, (b64, pad) in B64_PADDING_EXAMPLES.items():
            self.assertEqual(self._call(b64 + pad), text)

    def test_unicode_with_ascii(self):
        self.assertEqual(self._call(u'YQ'), b'a')

    def test_non_ascii_unicode_fails(self):
        self.assertRaises(ValueError, self._call, u'\u0105')

    def test_type_error_no_unicode_or_bytes(self):
        self.assertRaises(TypeError, self._call, object())


if __name__ == '__main__':
    unittest.main()  # pragma: no cover

Directory Contents

Dirs: 2 × Files: 20

Name Size Perms Modified Actions
testdata DIR
- drwxr-xr-x 2025-04-13 08:21:05
Edit Download
- drwxr-xr-x 2025-04-13 08:21:05
Edit Download
1.40 KB lrw-r--r-- 2021-09-09 21:33:18
Edit Download
2.20 KB lrw-r--r-- 2021-09-09 21:33:18
Edit Download
762 B lrw-r--r-- 2021-09-09 21:33:18
Edit Download
463 B lrw-r--r-- 2021-09-09 21:33:18
Edit Download
7.51 KB lrw-r--r-- 2021-09-09 21:33:18
Edit Download
3.51 KB lrw-r--r-- 2021-09-09 21:33:18
Edit Download
15.35 KB lrw-r--r-- 2021-09-09 21:33:18
Edit Download
13.83 KB lrw-r--r-- 2021-09-09 21:33:18
Edit Download
8.17 KB lrw-r--r-- 2021-09-09 21:33:18
Edit Download
8.80 KB lrw-r--r-- 2021-09-09 21:33:18
Edit Download
13.12 KB lrw-r--r-- 2021-09-09 21:33:18
Edit Download
12.69 KB lrw-r--r-- 2021-09-09 21:33:18
Edit Download
13.84 KB lrw-r--r-- 2021-09-09 21:33:18
Edit Download
8.32 KB lrw-r--r-- 2021-09-09 21:33:18
Edit Download
529 B lrw-r--r-- 2021-09-09 21:33:18
Edit Download
1.05 KB lrw-r--r-- 2021-09-09 21:33:18
Edit Download
2.57 KB lrw-r--r-- 2021-09-09 21:33:18
Edit Download
8.37 KB lrw-r--r-- 2021-09-09 21:33:18
Edit Download
8.15 KB lrw-r--r-- 2021-09-09 21:33:18
Edit Download
1.66 KB lrw-r--r-- 2021-09-09 21:33:18
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).
© 2026 REDROOM — Secure File Manager. All rights reserved. Built with ❤️ & Red Dark UI