diff options
author | Idan Moral <idan22moral@gmail.com> | 2021-07-19 22:42:19 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-19 22:42:19 (GMT) |
commit | 366fcbac18e3adc41e3901580dbedb6a91e41a10 (patch) | |
tree | 0abd9419519cb97908c0aa83229f03605ceae571 /Lib | |
parent | e25e43e3556db782b51e96f7da4207c4d7914b1e (diff) | |
download | cpython-366fcbac18e3adc41e3901580dbedb6a91e41a10.zip cpython-366fcbac18e3adc41e3901580dbedb6a91e41a10.tar.gz cpython-366fcbac18e3adc41e3901580dbedb6a91e41a10.tar.bz2 |
bpo-44678: Separate error message for discontinuous padding in binascii.a2b_base64 strict mode (GH-27249)
* Renamed assertLeadingPadding function to match logic
* Added a separate error message for discontinuous padding
* Updated the tests for discontinuous padding
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_binascii.py | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/Lib/test/test_binascii.py b/Lib/test/test_binascii.py index 74438d8..da8f9d1 100644 --- a/Lib/test/test_binascii.py +++ b/Lib/test/test_binascii.py @@ -130,9 +130,12 @@ class BinASCIITest(unittest.TestCase): def assertNonBase64Data(data, non_strict_mode_expected_result: bytes): _assertRegexTemplate(r'(?i)Only base64 data', data, non_strict_mode_expected_result) - def assertMalformedPadding(data, non_strict_mode_expected_result: bytes): + def assertLeadingPadding(data, non_strict_mode_expected_result: bytes): _assertRegexTemplate(r'(?i)Leading padding', data, non_strict_mode_expected_result) + def assertDiscontinuousPadding(data, non_strict_mode_expected_result: bytes): + _assertRegexTemplate(r'(?i)Discontinuous padding', data, non_strict_mode_expected_result) + # Test excess data exceptions assertExcessData(b'ab==a', b'i') assertExcessData(b'ab===', b'i') @@ -148,11 +151,11 @@ class BinASCIITest(unittest.TestCase): assertNonBase64Data(b'a\x00b==', b'i') # Test malformed padding - assertMalformedPadding(b'=', b'') - assertMalformedPadding(b'==', b'') - assertMalformedPadding(b'===', b'') - assertMalformedPadding(b'ab=c=', b'i\xb7') - assertMalformedPadding(b'ab=ab==', b'i\xb6\x9b') + assertLeadingPadding(b'=', b'') + assertLeadingPadding(b'==', b'') + assertLeadingPadding(b'===', b'') + assertDiscontinuousPadding(b'ab=c=', b'i\xb7') + assertDiscontinuousPadding(b'ab=ab==', b'i\xb6\x9b') def test_base64errors(self): |