MCPcopy Create free account
hub / github.com/python/cpython / test_ascii85_wrapcol

Method test_ascii85_wrapcol

Lib/test/test_binascii.py:569–605  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

567 func(data, wrapcol=None)
568
569 def test_ascii85_wrapcol(self):
570 # Test Ascii85 splitting lines
571 self._common_test_wrapcol(binascii.b2a_ascii85)
572
573 def assertEncode(a_expected, data, n, adobe=False):
574 b = self.type2test(data)
575 a = binascii.b2a_ascii85(b, adobe=adobe, wrapcol=n)
576 self.assertEqual(a, a_expected)
577
578 def assertDecode(data, b_expected, adobe=False):
579 a = self.type2test(data)
580 b = binascii.a2b_ascii85(a, adobe=adobe, ignorechars=b"\n")
581 self.assertEqual(b, b_expected)
582
583 tests = [
584 (b"", 0, b"", b"<~~>"),
585 (b"", 1, b"", b"<~\n~>"),
586 (b"a", 0, b"@/", b"<~@/~>"),
587 (b"a", 1, b"@\n/", b"<~\n@/\n~>"),
588 (b"a", 2, b"@/", b"<~\n@/\n~>"),
589 (b"a", 3, b"@/", b"<~@\n/~>"),
590 (b"a", 4, b"@/", b"<~@/\n~>"),
591 (b"a", 5, b"@/", b"<~@/\n~>"),
592 (b"a", 6, b"@/", b"<~@/~>"),
593 (b"a", 7, b"@/", b"<~@/~>"),
594 (b"a", 123, b"@/", b"<~@/~>"),
595 (b"this is a test", 7, b"FD,B0+D\nGm>@3BZ\n'F*%",
596 b"<~FD,B0\n+DGm>@3\nBZ'F*%\n~>"),
597 (b"a test!!!!!!! ", 11, b"@3BZ'F*&QK+\nX&!P+WqmM+9",
598 b"<~@3BZ'F*&Q\nK+X&!P+WqmM\n+9~>"),
599 (b"\0" * 56, 7, b"zzzzzzz\nzzzzzzz", b"<~zzzzz\nzzzzzzz\nzz~>"),
600 ]
601 for b, n, a, a_wrap in tests:
602 assertEncode(a, b, n)
603 assertEncode(a_wrap, b, n, adobe=True)
604 assertDecode(a, b)
605 assertDecode(a_wrap, b, adobe=True)
606
607 def test_ascii85_pad(self):
608 # Test Ascii85 with encode padding

Callers

nothing calls this directly

Calls 1

_common_test_wrapcolMethod · 0.95

Tested by

no test coverage detected