a zeU@sddlZddlmZddlZddlZddlZGdddejZGdddejZGdddejZ d Z d Z d Z d Z d ZdZdZdZGdddejZGdddejZGdddejZGdddejZGdddejZddZddZedkredS) N)findfilec@s$eZdZddZddZddZdS) TestWithAsciicCstddd}|j|ddd|t|ddg||jttddd}|j|ddd|t|gd ||jtdS) NZdbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbZeabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbgףp= ?Zplaces)insertrrr)equalrdreZebbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb))rr2rr )rr r r 3)rr r r r ) difflibSequenceMatcherassertAlmostEqualratio assertEquallist get_opcodesbpopularsetselfsmrE/opt/bitninja-python-dojo/embedded/lib/python3.9/test/test_difflib.pytest_one_insert szTestWithAscii.test_one_insertcCs>tddd}|j|ddd|t|gddS)NZQaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaacbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbPaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbg+?rr))rr(rr)deleter)rr)rrQrP)r rrrrrrrrrrtest_one_deletes zTestWithAscii.test_one_deletecCsrtjddddd}||jttjddddd}||jdhtjd dddd}||jdd hdS) NcSs|dkSN rxrrr!z*TestWithAscii.test_bjunk..rZTaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb)ZisjunkabcSs|dkSr#rr%rrrr'%r(zhaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb r$cSs|dvS)N)r$r*rr%rrrr')r(r*)r rrZbjunkrrrrr test_bjunk s   zTestWithAscii.test_bjunkN)__name__ __module__ __qualname__rr"r+rrrrrsrc@seZdZdZddZdS) TestAutojunkz-Tests for the autojunk parameter added in 2.7cCstd}d}td||}|j|ddd||jdhtjd||dd}|j|d dd||jtdS) NZbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbZabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbrrrr*F)ZautojunkgQ?)r rrrrrr)rZseq1Zseq2rrrr#test_one_insert_homogenous_sequence0sz0TestAutojunk.test_one_insert_homogenous_sequenceN)r,r-r.__doc__r0rrrrr/.sr/c@s<eZdZddZddZddZddZd d Zd d Zd S) TestSFbugscCsBtdgg}||d||d||ddS)Nr)r rrrZ quick_ratioZreal_quick_ratio)rsrrrtest_ratio_for_null_seqnAsz#TestSFbugs.test_ratio_for_null_seqncCs>tdgg}|tt|tgg}|tt|dSN)r rZget_grouped_opcodes assertRaises StopIterationnext unified_diff)rZ group_genZdiff_genrrrtest_comparing_empty_listsHs z%TestSFbugs.test_comparing_empty_listscCsXtddd}|}|}||djd||djd||djddS)NZabxcdZabcdrr)r rZget_matching_blocksrsize)rr3firstsecondrrrtest_matching_blocks_cacheOs z%TestSFbugs.test_matching_blocks_cachecCs\ttdgdg}|d|d|d|d|d|d|d |d dS) Nz I am a buggyz I am a bugz- I am a buggyrz? -- rz+ I am a bugr;z? + rrr ZDifferZcomparerrdiffrrrtest_added_tab_hintXs zTestSFbugs.test_added_tab_hintcCsLttdgdg}|d|d|d|d|d|ddS) Nz ^z ^ z- ^rz + ^ rz ? + r;r@rArrr%test_hint_indented_properly_with_tabs`sz0TestSFbugs.test_hint_indented_properly_with_tabscCs$|ttdgdgddgdS)N23r))rz-2)rz+3T)rrr Z_mdiffrrrrtest_mdiff_catch_stop_iterationfsz*TestSFbugs.test_mdiff_catch_stop_iterationN) r,r-r.r4r:r?rCrDrHrrrrr2@s  r2z 1. Beautiful is beTTer than ugly. 2. Explicit is better than implicit. 3. Simple is better than complex. 4. Complex is better than complicated. z 1. Beautiful is better than ugly. 3. Simple is better than complex. 4. Complicated is better than complex. 5. Flat is better than nested. u 1. Beautiful is beTTer than ugly. 2. Explicit is better than ımplıcıt. 3. Simple is better than complex. 4. Complex is better than complicated. u 1. Beautiful is better than ügly. 3. Sımple is better than complex. 4. Complicated is better than cömplex. 5. Flat is better than nested. z Line 1: preceded by from:[tt] to:[ssss] Line 2: preceded by from:[sstt] to:[sssst] Line 3: preceded by from:[sstst] to:[ssssss] Line 4: has from:[sst] to:[sss] after : Line 5: has from:[t] to:[ss] at end z Line 1: preceded by from:[tt] to:[ssss] Line 2: preceded by from:[sstt] to:[sssst] Line 3: preceded by from:[sstst] to:[ssssss] Line 4: has from:[sst] to:[sss] after : Line 5: has from:[t] to:[ss] at end zline 0 1234567890123456789012345689012345 line 1 line 2 line 3 line 4 changed line 5 changed line 6 changed line 7 line 8 subtracted line 9 1234567890123456789012345689012345 short line just fits in!! just fits in two lines yup!! the endzline 0 1234567890123456789012345689012345 line 1 line 2 added line 3 line 4 chanGEd line 5a chanGed line 6a changEd line 7 line 8 line 9 1234567890 another long line that needs to be wrapped just fitS in!! just fits in two lineS yup!! the endc@s4eZdZddZddZddZddZd d Zd S) TestSFpatchesc!Cstdd}tdd}d|}d|}|}|}|}|}t}t}t}t}t} tjdd} tjdd} | j ||dd d d d } d d| j ||dd ddd| j ||dd ddd| j ||dd ddd d| j ||dd ddd d| j ||dd ddd| j ||dd d dd| j ggdd ddd| j ggdd d dd| ||d| ||d| j ||ddd d| ||d| |d|dg} | dd | }t td! }|||Wdn1s0YdS)"Nz(123 123 123 123 123 123 123 123 123 123 rz(456 456 456 456 456 456 456 456 456 456 r;)tabsize)Z wrapcolumnfromtoF)contextZnumlines z8

Context (first diff within numlines=5(default))

T)rOz7

Context (first diff after numlines=5(default))

z

Context (numlines=6)

z

Context (numlines=0)

rz

Same Context

z

Same Full

z

Empty Context

z

Empty Full

z

tabsize=2

z

tabsize=default

z+

Context (wrapcolumn=14,numlines=0)

z#

wrapcolumn=14,splitlines()

z'

wrapcolumn=14,splitlines(True)

zz %s ztest_difflib_expect.html)patch914575_from1patch914575_to1 splitlinespatch914575_from2patch914575_to2patch914575_from3patch914575_to3r HtmlDiff make_filejoinZ make_tablereplaceopenrrread)rZf1aZt1aZf1bZt1bf2t2Zf3Zt3ijkfullZtablesactualfprrrtest_html_diffs`      zTestSFpatches.test_html_diffcCsJt}ddt|dD}ddt|dD}td||dS)NcSs g|]}|drdpd|qS)r;K:%dzV:A:%dr.0rarrr r(z6TestSFpatches.test_recursion_limit..r;cSs g|]}|drdpd|qS)r;rhzV:B:%drrirrrrkr()sysgetrecursionlimitranger rr)rlimitoldnewrrrtest_recursion_limitsz"TestSFpatches.test_recursion_limitcCs,t}|tt}|d|dS)Nz"content="text/html; charset=utf-8"r rYrZrRrTrSassertInrZ html_diffoutputrrrtest_make_file_default_charsets  z,TestSFpatches.test_make_file_default_charsetcCs0t}|jttdd}|d|dS)Nz iso-8859-1charsetz'content="text/html; charset=iso-8859-1"rsrurrrtest_make_file_iso88591_charsets  z-TestSFpatches.test_make_file_iso88591_charsetcCs<t}|jttdd}|d||d|dS)Nzus-asciirxz%content="text/html; charset=us-ascii"zımplıcıt)r rYrZpatch914575_nonascii_from1rTpatch914575_nonascii_to1rtrurrr2test_make_file_usascii_charset_with_nonascii_input s  z@TestSFpatches.test_make_file_usascii_charset_with_nonascii_inputN)r,r-r.rgrrrwrzr}rrrrrIs 9rIc@s,eZdZddZddZddZddZd S) TestOutputFormatcCsdgd}tj|ddi}|t|ddddgtj|ddi}|t|dddd gdS) N)onetwoOriginalCurrentz2005-01-26 23:30:50z2010-04-02 10:20:52linetermrr;z --- Original 2005-01-26 23:30:50z+++ Current 2010-04-02 10:20:52z *** Original 2005-01-26 23:30:50z--- Current 2010-04-02 10:20:52r r9rr context_diffrargsZudZcdrrrtest_tab_delimitersz#TestOutputFormat.test_tab_delimitercCsdgd}tj|ddi}|t|ddddgtj|ddi}|t|dddd gdS) N)rrrrrrrr;z --- Originalz +++ Currentz *** Originalz --- Currentrrrrr&test_no_trailing_tab_on_empty_filedate!s z7TestOutputFormat.test_no_trailing_tab_on_empty_filedatecCshd}tj}||ddd||ddd||ddd||ddd ||d d d dS) Na Each field shall be of the form: %1d", if the range contains exactly one line, and: "%1d,%1d", , otherwise. If a range is empty, its beginning line number shall be the number of the line just before the range, or 0 if the empty range starts the file. rz3,04rNz4,2rQz4,3rz0,0)r Z_format_range_unifiedrrspecfmtrrrtest_range_format_unified)sz*TestOutputFormat.test_range_format_unifiedcCshd}tj}||ddd||ddd||ddd||ddd ||d d d dS) Na The range of lines in file1 shall be written in the following format if the range contains two or more lines: "*** %d,%d **** ", , and the following format otherwise: "*** %d **** ", The ending line number of an empty range shall be the number of the preceding line, or 0 if the range is at the start of the file. Next, the range of lines in file2 shall be written in the following format if the range contains two or more lines: "--- %d,%d ---- ", , and the following format otherwise: "--- %d ---- ", rrFrrrNz4,5rQz4,6r0)r Z_format_range_contextrrrrrtest_range_format_context:sz*TestOutputFormat.test_range_format_contextN)r,r-r.rrrrrrrrr~s r~c@sDeZdZddZddZddZddZd d Zd d Zd dZ dS) TestBytescCs(t|}|D]}||td|q dS)Nz.all lines of diff should be bytes, but got: %r)rZassertIsInstancebytes)rrBlinerrrcheckVs zTestBytes.checkc Cs.ddg}ddg}tj}tj}|j}|t||||t||||t|||dd|t|||dd|t|||dddd|t|||dddd|t||||t||||t|||dd|t|||dd|t|||dddd|t|||dddddS)Nhellosandrsandréabs2005s2013)r r9rr diff_bytes)rr)r*unifiedrOrrrrtest_byte_content]s"zTestBytes.test_byte_contentc sd}d}dg}dg}j}tj}tj}|t||||||t|||||fdd}gd} tj|||||dd } || | d } d } |t|||||| | |t|||||| | gd } tj|||||| | dd } || | dS) Nsodz.txts łodz.txtsodz is a city in Poland.sŁodz is a city in Poland.cs@t|}t|t|t||D]\}}||q&dSr5)rrlenzip)expectreer)rGrr assertDiffsz1TestBytes.test_byte_filenames..assertDiff)s --- odz.txts +++ łodz.txt @@ -1 +1 @@-odz is a city in Poland.+Łodz is a city in Poland.r()rs 2005-03-18s 2005-03-19)s--- odz.txt 2005-03-18s+++ łodz.txt 2005-03-19rrr)rr r9rr) rfnafnbr)r*rrrOrrredateadatebrrGrtest_byte_filenamesys,   zTestBytes.test_byte_filenamescCsdg}dg}tj}tj}d}||||||||||||||||||||d}||tj|||||tj|||||tj|||||tj|||dS)NrZhelloz2lines to compare must be str, not bytes (b'hello')z.all arguments must be bytes, not str ('hello'))r r9r_assert_type_errorr)rr)r*rrOrrrrtest_mixed_types_contentsz"TestBytes.test_mixed_types_contentcCs.dg}dg}d}d}|dtj||||dS)Nzhello zohell sol.txts ola9.txtz-all arguments must be str, not: b'ol\xe9.txt')rr r9)rr)r*rrrrrtest_mixed_types_filenamess z$TestBytes.test_mixed_types_filenamesc CsZdg}dg}d}d}|dtjtj||dd|| dg}d g}tt||d d ||dS) Nsfoo sbar u1 févu3 févu/all arguments must be bytes, not str ('1 fév')rrzfoo zbar r)r*)rr rr9r)rr)r*rrrrrtest_mixed_types_datess z TestBytes.test_mixed_types_datescGsL|t}t||Wdn1s,0Y||t|jdSr5)r6 TypeErrorrrstr exception)rmsg generatorrctxrrrrs *zTestBytes._assert_type_errorN) r,r-r.rrrrrrrrrrrrSs5 rc@s4eZdZddZddZddZddZd d Zd S) TestJunkAPIscCs$dD]}|t|t|qdS)N)#z z #z# z # r) assertTruer IS_LINE_JUNKreprrrrrrtest_is_line_junk_truesz#TestJunkAPIs.test_is_line_junk_truecCs$dD]}|t|t|qdS)N)##z ##z## zabc zabc #zMr. Moose is up!) assertFalser rrrrrrtest_is_line_junk_falsesz$TestJunkAPIs.test_is_line_junk_falsecCs ddd}|t|dS)N i@Br)rr r)rZ evil_inputrrrtest_is_line_junk_REDOSs z$TestJunkAPIs.test_is_line_junk_REDOScCs$dD]}|t|t|qdS)N)r$r)rr IS_CHARACTER_JUNKrrcharrrrtest_is_character_junk_truesz(TestJunkAPIs.test_is_character_junk_truecCs$dD]}|t|t|qdS)N)r)rrP   )rr rrrrrrtest_is_character_junk_falsesz)TestJunkAPIs.test_is_character_junk_falseN)r,r-r.rrrrrrrrrrs rc@s$eZdZddZddZddZdS)TestFindLongestcs8tfddfddtdtdDDS)Nc3s|]}|vVqdSr5r)rjZb_part)r)rr r(z6TestFindLongest.longer_match_exists..cs g|]}||dqS)rrri)r*nrrrkr(z7TestFindLongest.longer_match_exists..rr)anyrnr)rr)r*rr)r)r*rrlonger_match_existss $z#TestFindLongest.longer_match_existscCsd}d}tj||d}|}||jd||jd||jd|||j|j|j||j|j|j|||||j|jddd}||jd ||jd ||jd|||j|j|j||j|j|j|||dd|dd|j|jd d d }||jd ||jd ||jd|||j|j|j||j|j|j||||d d |jdS)Nzfoo barz foo baz barr)r*rrQr;r)ZaloblorrNr)Zbhir) r rfind_longest_matchrr)r*r<rrrr)r*rmatchrrrtest_default_argss6&z!TestFindLongest.test_default_argscCsd}d}tj||d}|dt|dt|}||jd||jd||jd|||j|j|j||j|j|j|| |||jdS)NZdabcdZddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddabcddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddrrcrN) r rrrrr)r*r<rrrrrr%test_longest_match_with_popular_charssz5TestFindLongest.test_longest_match_with_popular_charsN)r,r-r.rrrrrrrrsrcCs dtj_dS)Nr)r rYZ_default_prefixrrrr setUpModule&srcCs|tt|Sr5)ZaddTestdoctestZ DocTestSuiter )loaderZtestspatternrrr load_tests*sr__main__)r Z test.supportrZunittestrrlZTestCaserr/r2rRrSr{r|rUrVrWrXrIr~rrrrrr,mainrrrrs2 &.X?.