a  zeN@sddlZddlmZddlmZddlmZGdddeZGdddeZGd d d eZ Gd d d eZ Gd ddeZ GdddeZ e dkredS)N)_encoded_words)errors) TestEmailBasec@s0eZdZgfddZddZddZddZd S) TestDecodeQcCs*t|\}}||||||dSN)_ewZdecode_q assertEqualassertDefectsEqualselfsourceZ ex_resultZ ex_defectsresultdefectsrW/opt/bitninja-python-dojo/embedded/lib/python3.9/test/test_email/test__encoded_words.py_test s zTestDecodeQ._testcCs|dddS)Nfoobarrr rrrtest_no_encodedszTestDecodeQ.test_no_encodedcCs|dd|dddS)Ns foo=20bar=20foo bar sfoo_bar_rrrrr test_spacess zTestDecodeQ.test_spacescCs|dddS)Nsfoo=20=20=21=2Cbars foo !,barrrrrrtest_run_of_encodedszTestDecodeQ.test_run_of_encodedN)__name__ __module__ __qualname__rrrrrrrrrs rc@s@eZdZgfddZddZddZddZd d Zd d Zd S) TestDecodeBcCs*t|\}}||||||dSr)rZdecode_brr r rrrrs zTestDecodeB._testcCs|dddS)NsZm9vfoorrrrr test_simple szTestDecodeB.test_simplecCs(|ddtjg|ddtjgdS)NsdmkvisdgvrrInvalidBase64PaddingDefectrrrrtest_missing_padding#sz TestDecodeB.test_missing_paddingcCs|ddtjgdS)Nsdmk===rrrInvalidBase64CharactersDefectrrrrtest_invalid_character)sz"TestDecodeB.test_invalid_charactercCs|ddtjtjgdS)Nsdmkrrrr%r"rrrr&test_invalid_character_and_bad_padding,s z2TestDecodeB.test_invalid_character_and_bad_paddingcCs|ddtjgdS)Nsabcde)rrZInvalidBase64LengthDefectrrrrtest_invalid_length0szTestDecodeB.test_invalid_lengthN) rrrrrr#r&r(r)rrrrrs  rc@seZdZddZddgfddZddZd d Zd d Zd dZddZ ddZ ddZ ddZ ddZ ddZddZddZdd Zd!d"Zd#S)$ TestDecodecCs|ttdWdn1s*0Y|ttdWdn1s^0Y|ttdWdn1s0Y|ttdWdn1s0YdS)Nz =?badone?=z=?z=?utf-8?X?somevalue?=)Z assertRaises ValueErrorrdecodeKeyErrorrrrrtest_wrong_format_input_raises6s ( ( ( z)TestDecode.test_wrong_format_input_raisesus-asciir+c CsFt|\}}}} ||||||||||| |dSr)rr-rr ) r r r charsetlangrrescharldrrrr@s    zTestDecode._testcCs|dddS)Nz=?us-ascii?q?foo?=foorrrrr test_simple_qGszTestDecode.test_simple_qcCs|dddS)Nz=?us-ascii?b?dmk=?=virrrrr test_simple_bJszTestDecode.test_simple_bcCs|dddS)Nz=?us-ascii?Q?foo?=r7rrrrrtest_q_case_ignoredMszTestDecode.test_q_case_ignoredcCs|dddS)Nz=?us-ascii?B?dmk=?=r9rrrrrtest_b_case_ignoredPszTestDecode.test_b_case_ignoredcCs|ddddS)Nz!=?latin-1?q?=20F=fcr=20Elise=20?=u Für Elise zlatin-1rrrrrtest_non_trivial_qSszTestDecode.test_non_trivial_qcCs |jddddtjgddS)Ns=?us-ascii?q?=20foo?=r0surrogateescapeu foor)rr-rZUndecodableBytesDefectrrrrtest_q_escaped_bytes_preservedVs  z)TestDecode.test_q_escaped_bytes_preservedcCs$|jddddtjtjgddS)Ns=?us-ascii?b?dmk?=r0r>r9r?)rr-rr%r"rrrr,test_b_undecodable_bytes_ignored_with_defect\s z7TestDecode.test_b_undecodable_bytes_ignored_with_defectcCs|jddtjgddS)Nz=?us-ascii?b?dmk===?=r9r?r$rrrr(test_b_invalid_bytes_ignored_with_defectdsz3TestDecode.test_b_invalid_bytes_ignored_with_defectcCs|jddtjtjgddS)Nz=?us-ascii?b?dmk?=r9r?r'rrrr&test_b_invalid_bytes_incorrect_paddingis z1TestDecode.test_b_invalid_bytes_incorrect_paddingcCs|jddtjgddS)Nz=?us-ascii?b?dmk?=r9r?r!rrrrtest_b_padding_defectpsz TestDecode.test_b_padding_defectcCs|jdddddS)Nz=?us-ascii*jive?q?test?=testjiver2rrrrrtest_nonnull_languszTestDecode.test_nonnull_langcCs|jdddddgddS)N=?unknown-8bit?q?foo=ACbar?=foobarasciir> unknown-8bitr1r)rr-rrrrtest_unknown_8bit_charsetxs  z$TestDecode.test_unknown_8bit_charsetcCs"|jdddddtjgddS)Nz=?foobar?q?foo=ACbar?=rJrKr>foobarrM)rr-rZ CharsetErrorrrrrtest_unknown_charset~s  zTestDecode.test_unknown_charsetcCs|jdddddS)Nz=?utf-8?q?=C3=89ric?=uÉricutf-8r1rrrrrtest_q_nonasciiszTestDecode.test_q_nonasciiN)rrrr/rr8r:r;r<r=r@rArBrCrDrHrNrPrSrrrrr*4s  r*c@s,eZdZddZddZddZddZd S) TestEncodeQcCs|t||dSr)rrZencode_q)r srcZexpectedrrrrszTestEncodeQ._testcCs|dddS)NrrOrrrrr test_all_safeszTestEncodeQ.test_all_safecCs|dddS)NrZfoo_bar_rrrrrrszTestEncodeQ.test_spacescCs|dddS)Ns foo ,,barzfoo__=2C=2Cbarrrrrrtest_run_of_encodablessz"TestEncodeQ.test_run_of_encodablesN)rrrrrVrrWrrrrrTsrTc@seZdZddZddZdS) TestEncodeBcCs|tdddS)NrZZm9vrrZencode_brrrrrszTestEncodeB.test_simplecCs|tdddS)Nrzdmk=rYrrrr test_paddingszTestEncodeB.test_paddingN)rrrrrZrrrrrXsrXc@s\eZdZddZddZddZddZd d Zd d Zd dZ ddZ ddZ ddZ dS) TestEncodecCs|tdddddS)Nr7rQq=?utf-8?q?foo?=rrencoderrrrtest_qszTestEncode.test_qcCs|tdddddS)Nr7rQbz=?utf-8?b?Zm9v?=r^rrrrtest_bszTestEncode.test_bcCs|tddddS)Nr7rQr]r^rrrr test_auto_qszTestEncode.test_auto_qcCs|tddddS)Nzvi.rQz=?utf-8?q?vi=2E?=r^rrrr test_auto_q_if_short_mostly_safesz+TestEncode.test_auto_q_if_short_mostly_safecCs|tddddS)Nz.....rQz=?utf-8?b?Li4uLi4=?=r^rrrrtest_auto_b_if_enough_unsafesz'TestEncode.test_auto_b_if_enough_unsafecCs|tddddS)Nzvi.vi.vi.vi.vi.rQz =?utf-8?b?dmkudmkudmkudmkudmku?=r^rrrrtest_auto_b_if_long_unsafesz%TestEncode.test_auto_b_if_long_unsafecCs|tddddS)Nz vi vi vi.vi rQz=?utf-8?q?vi_vi_vi=2Evi_?=r^rrrrtest_auto_q_if_long_mostly_safesz*TestEncode.test_auto_q_if_long_mostly_safecCs|tdddS)Nr7r]r^rrrrtest_utf8_defaultszTestEncode.test_utf8_defaultcCs|tjdddddS)Nr7rFrGz=?utf-8*jive?q?foo?=r^rrrr test_langszTestEncode.test_langcCs|tjdddddS)Nu foobarrLrRrIr^rrrrtest_unknown_8bitszTestEncode.test_unknown_8bitN) rrrr`rbrcrdrerfrgrhrirjrrrrr[sr[__main__)ZunittestZemailrrrZtest.test_emailrrrr*rTrXr[rmainrrrrs   W $