Your IP : 216.73.216.85


Current Path : /opt/alt/python35/lib64/python3.5/test/__pycache__/
Upload File :
Current File : //opt/alt/python35/lib64/python3.5/test/__pycache__/test_difflib.cpython-35.opt-2.pyc



���]�L�@sHddlZddlmZmZddlZddlZddlZGdd�dej�ZGdd�dej�Z	Gdd�dej�Z
d	Zd
ZdZ
dZd
ZdZdZdZGdd�dej�ZGdd�dej�ZGdd�dej�ZGdd�dej�Zdd�ZedkrDe�dS)�N)�run_unittest�findfilec@s4eZdZdd�Zdd�Zdd�ZdS)�
TestWithAsciic	Cs�tjdddddd�}|j|j�ddd�|jt|j��ddg�|j|jt��tjdddddddd�}|j|j�ddd�|jt|j��dddg�|j|jt��dS)N�b�d�agףp=
��?�places��insertr��equal�e�2�3)r
rrrr)rrrrr
)rrrrr)r
rrrr)rrrrr
)	�difflib�SequenceMatcher�assertAlmostEqual�ratio�assertEqual�list�get_opcodes�bpopular�set)�self�sm�r�1/opt/alt/python35/lib64/python3.5/test_difflib.py�test_one_insert	s!
)
zTestWithAscii.test_one_insertc	Csvtjdddddddddd�}|j|j�ddd�|jt|j��dddg�dS)Nr�(�crg+����?rr	rr�delete�)�Q�P)rrrrr)r rr!rr)rr!r"rr#)rrrrrrr)rrrrr�test_one_deletes1zTestWithAscii.test_one_deletec	Cstjddd�dddddddddd�}|j|jt��tjddd�ddddddddddd�}|j|jd	h�tjddd�ddddddddddd
�}|j|jd	dh�dS)NZisjunkcSs
|dkS)N� r)�xrrr�<lambda>!sz*TestWithAscii.test_bjunk.<locals>.<lambda>rrr�,cSs
|dkS)Nr%r)r&rrrr'%sr%�cSs
|dkS)Nr%r)r%rr)r&rrrr')sz                    z                    )rrrZbjunkr)rrrrr�
test_bjunk s'++zTestWithAscii.test_bjunkN)�__name__�
__module__�__qualname__rr$r*rrrrrsrc@seZdZdd�ZdS)�TestAutojunkcCs�dd}ddd}tjd||�}|j|j�ddd�|j|jdh�tjd||dd�}|j|j�d	dd�|j|jt��dS)
Nr��rrrr	ZautojunkFg�Q����?)rrrrrrr)rZseq1Zseq2rrrr�#test_one_insert_homogenous_sequence0s
z0TestAutojunk.test_one_insert_homogenous_sequenceN)r+r,r-r0rrrrr..sr.c@s@eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�
TestSFbugscCs[tjdgg�}|j|j�d�|j|j�d�|j|j�d�dS)Nr)rrrrZquick_ratioZreal_quick_ratio)r�srrr�test_ratio_for_null_seqnAsz#TestSFbugs.test_ratio_for_null_seqncCsWtjdgg�j�}|jtt|�tjgg�}|jtt|�dS)N)rrZget_grouped_opcodes�assertRaises�
StopIteration�next�unified_diff)rZ	group_genZdiff_genrrr�test_comparing_empty_listsHsz%TestSFbugs.test_comparing_empty_listscCsvtjddd�}|j�}|j�}|j|djd�|j|djd�|j|djd�dS)NZabxcdZabcdr�r)rrZget_matching_blocksr�size)rr2�first�secondrrr�test_matching_blocks_cacheOsz%TestSFbugs.test_matching_blocks_cachecCsxttj�jdgdg��}|jd|d�|jd|d�|jd|d�|jd	|d
�dS)Nz
	I am a buggyz		I am a bugz- 	I am a buggyrz?            --
rz+ 		I am a bugr9z? +
r	)rrZDifferZcomparer)r�diffrrr�test_added_tab_hintXs
$zTestSFbugs.test_added_tab_hintN)r+r,r-r3r8r=r?rrrrr1@s	r1z�
   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: preceeded by from:[tt] to:[ssss]
  		Line 2: preceeded by from:[sstt] to:[sssst]
  	 	Line 3: preceeded 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: preceeded by from:[tt] to:[ssss]
    	Line 2: preceeded by from:[sstt] to:[sssst]
      Line 3: preceeded by from:[sstst] to:[ssssss]
Line 4:   has from:[sst] to:[sss] after :
Line 5: has from:[t] to:[ss] at end
z�line 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 endz�line 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@sLeZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)�
TestSFpatchescCs�tddd}tddd}dd|}dd|}|j�}|j�}|j�}|j�}tj�}tj�}t}t}tj�}	tjdd�}
tjdd�}|	j	||d	d
ddd
d�}dj
d|	j||d	d
dd�d|	j||d	d
dd�d|	j||d	d
ddd
d�d|	j||d	d
ddd
d�d|	j||d	d
dd�d|	j||d	d
dd�d|	jggd	d
dd�d|	jggd	d
dd�d|
j||�d|	j||�d|j|j�|j�ddd
d�d|j|j�|j��d|j|jd�|jd��g�}
|jd d!|
�}t
td"���}|j||j��WdQRXdS)#Nz123
�
r	z456
�tabsizer9Z
wrapcolumn��fromZto�contextFZnumlines��
z8<h2>Context (first diff within numlines=5(default))</h2>Tz7<h2>Context (first diff after numlines=5(default))</h2>z<h2>Context (numlines=6)</h2>�z<h2>Context (numlines=0)</h2>rz<h2>Same Context</h2>z<h2>Same Full</h2>z<h2>Empty Context</h2>z<h2>Empty Full</h2>z<h2>tabsize=2</h2>z<h2>tabsize=default</h2>z+<h2>Context (wrapcolumn=14,numlines=0)</h2>z#<h2>wrapcolumn=14,splitlines()</h2>z'<h2>wrapcolumn=14,splitlines(True)</h2>z</body>z
%s
</body>ztest_difflib_expect.html)�patch914575_from1�patch914575_to1�
splitlines�patch914575_from2�patch914575_to2�patch914575_from3�patch914575_to3r�HtmlDiff�	make_file�joinZ
make_table�replace�openrr�read)rZf1aZt1aZf1bZt1b�f2Zt2Zf3Zt3�i�j�k�fullZtables�actual�fprrr�test_html_diff�s\$!!'*zTestSFpatches.test_html_diffcCsctj�}dd�t|d�D�}dd�t|d�D�}tjd||�j�dS)NcSs*g|] }|drdpd|�qS)r9zK:%dzV:A:%dr)�.0rWrrr�
<listcomp>�s	z6TestSFpatches.test_recursion_limit.<locals>.<listcomp>r9cSs*g|] }|drdpd|�qS)r9zK:%dzV:B:%dr)r^rWrrrr_�s	)�sys�getrecursionlimit�rangerrr)r�limit�old�newrrr�test_recursion_limit�sz"TestSFpatches.test_recursion_limitcCs>tj�}|jtj�tj��}|jd|�dS)Nz"content="text/html; charset=utf-8")rrPrQrIrKrJ�assertIn)r�	html_diff�outputrrr�test_make_file_default_charset�sz,TestSFpatches.test_make_file_default_charsetcCsDtj�}|jtj�tj�dd�}|jd|�dS)N�charsetz
iso-8859-1z'content="text/html; charset=iso-8859-1")rrPrQrIrKrJrg)rrhrirrr�test_make_file_iso88591_charset�s
	z-TestSFpatches.test_make_file_iso88591_charsetcCsTtj�}|jtj�tj�dd�}|jd|�|jd|�dS)Nrkzus-asciiz%content="text/html; charset=us-ascii"z&#305;mpl&#305;c&#305;t)rrPrQ�patch914575_nonascii_from1rK�patch914575_nonascii_to1rg)rrhrirrr�2test_make_file_usascii_charset_with_nonascii_input�s	z@TestSFpatches.test_make_file_usascii_charset_with_nonascii_inputN)r+r,r-r]rfrjrlrorrrrr@�s
9r@c@s@eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�TestOutputFormatcCs�ddddddg}tj|dd�}|jt|�d	d
�ddg�tj|dd�}|jt|�d	d
�d
dg�dS)N�one�two�Original�Currentz2005-01-26 23:30:50z2010-04-02 10:20:52�lineterm�rr9z --- 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:52)rr7rr�context_diff)r�args�ud�cdrrr�test_tab_delimiters
z#TestOutputFormat.test_tab_delimitercCs�ddddg}tj|dd�}|jt|�dd�d	d
g�tj|dd�}|jt|�dd�ddg�dS)
Nrqrrrsrtrurvrr9z--- Originalz+++ Currentz*** Originalz--- Current)rr7rrrw)rrxryrzrrr�&test_no_trailing_tab_on_empty_filedates
&z7TestOutputFormat.test_no_trailing_tab_on_empty_filedatecCs�d}tj}|j|dd�d�|j|dd�d�|j|dd�d�|j|dd�d	�|j|d
d
�d�dS)Na�           Each <range> field shall be of the form:
             %1d", <beginning line number>  if the range contains exactly one line,
           and:
            "%1d,%1d", <beginning line number>, <number of lines> 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.
        r	z3,0��4rFz4,2rHz4,3rz0,0)rZ_format_range_unifiedr)r�spec�fmtrrr�test_range_format_unifieds		z*TestOutputFormat.test_range_format_unifiedcCs�d}tj}|j|dd�d�|j|dd�d�|j|dd�d�|j|dd�d	�|j|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 ****
", <beginning line number>, <ending line number>
           and the following format otherwise:
               "*** %d ****
", <ending line number>
           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 ----
", <beginning line number>, <ending line number>
           and the following format otherwise:
               "--- %d ----
", <ending line number>
        r	�3r}r~rFz4,5rHz4,6r�0)rZ_format_range_contextr)rrr�rrr�test_range_format_context,s	z*TestOutputFormat.test_range_format_contextN)r+r,r-r{r|r�r�rrrrrpsrpc@sdeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dS)�	TestBytescCs8t|�}x%|D]}|j|td|�qWdS)Nz.all lines of diff should be bytes, but got: %r)rZassertIsInstance�bytes)rr>�linerrr�checkHs

zTestBytes.checkc	Cs�ddg}ddg}tj}tj}|j}|tj|||��|tj|||��|tj|||dd��|tj|||dd��|tj|||dddd��|tj|||dddd��|tj|||��|tj|||��|tj|||dd��|tj|||dd��|tj|||dddd��|tj|||dddd��dS)Nshellosandr�sandré�a�bs2005s2013)rr7rwr��
diff_bytes)rrr�unifiedrEr�rrr�test_byte_contentOs"			%%%zTestBytes.test_byte_contentc

sod}d}dg}dg}�j}tj}tj}|tj|||||��|tj|||||���fdd�}ddd	d
dg}	tj|||||dd
�}
||	|
�d}d}|tj|||||||��|tj|||||||��ddd	d
dg}	tj|||||||dd
�}
||	|
�dS)Ns�odz.txts	łodz.txts�odz is a city in Poland.sŁodz is a city in Poland.cs\t|�}�jt|�t|��x-t||�D]\}}�j||�q8WdS)N)rr�len�zip)�expectr[�er)rrr�
assertDiffzsz1TestBytes.test_byte_filenames.<locals>.assertDiffs--- �odz.txts
+++ łodz.txts@@ -1 +1 @@s-�odz is a city in Poland.s+Łodz is a city in Poland.ru�s
2005-03-18s
2005-03-19s--- �odz.txt	2005-03-18s+++ łodz.txt	2005-03-19)r�rr7rwr�)
r�fna�fnbrrr�r�rEr�r�r[�datea�datebr)rr�test_byte_filenamesks:							!
%%		zTestBytes.test_byte_filenamescCs�dg}dg}tj}tj}d}|j||||�|j||||�|j||||�|j||||�d}|j|tj|||�|j|tj|||�|j|tj|||�|j|tj|||�dS)NshelloZhelloz2lines to compare must be str, not bytes (b'hello')z.all arguments must be bytes, not str ('hello'))rr7rw�_assert_type_errorr�)rrrr�rEr�rrr�test_mixed_types_content�s				z"TestBytes.test_mixed_types_contentcCsAdg}dg}d}d}|jdtj||||�dS)Nzhello
zohell
sol�.txts	ol�a9.txtz-all arguments must be str, not: b'ol\xe9.txt')r�rr7)rrrr�r�rrr�test_mixed_types_filenames�s		z$TestBytes.test_mixed_types_filenamesc
Cs�dg}dg}d}d}|jdtjtj||dd||�	dg}d	g}ttj||d
d||��dS)Nsfoo
sbar
u1 févu3 févu/all arguments must be bytes, not str ('1 fév')r�r�zfoo
zbar
rr)r�rr�r7r)rrrr�r�rrr�test_mixed_types_dates�s				z TestBytes.test_mixed_types_datescGsF|jt��}t||��WdQRX|j|t|j��dS)N)r4�	TypeErrorrr�str�	exception)r�msg�	generatorrx�ctxrrrr��szTestBytes._assert_type_errorN)
r+r,r-r�r�r�r�r�r�r�rrrrr�Es5r�c@sLeZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)�TestJunkAPIscCsFx?ddddddgD]%}|jtj|�t|��qWdS)N�#z  z #z# z # rv)�
assertTruer�IS_LINE_JUNK�repr)rr�rrr�test_is_line_junk_true�sz#TestJunkAPIs.test_is_line_junk_truecCsFx?ddddddgD]%}|jtj|�t|��qWdS)Nz##z ##z## zabc zabc #zMr. Moose is up!)�assertFalserr�r�)rr�rrr�test_is_line_junk_false�sz$TestJunkAPIs.test_is_line_junk_falsecCs(ddd}|jtj|��dS)N�	i@Bz##)r�rr�)rZ
evil_inputrrr�test_is_line_junk_REDOS�sz$TestJunkAPIs.test_is_line_junk_REDOScCs:x3ddgD]%}|jtj|�t|��q
WdS)Nr%r�)r�r�IS_CHARACTER_JUNKr�)r�charrrr�test_is_character_junk_true�sz(TestJunkAPIs.test_is_character_junk_truecCsFx?ddddddgD]%}|jtj|�t|��qWdS)Nrr�rG��
�)r�rr�r�)rr�rrr�test_is_character_junk_false�sz)TestJunkAPIs.test_is_character_junk_falseN)r+r,r-r�r�r�r�r�rrrrr��s
r�c	Cs>dtj_tjt�}ttttt	t
tt|�dS)Nr)
rrPZ_default_prefix�doctestZDocTestSuiterrr.r@r1rpr�r�)ZDoctestsrrr�	test_main�s
r��__main__)rZtest.supportrrZunittestr�r`ZTestCaserr.r1rIrJrmrnrLrMrNrOr@rpr�r�r�r+rrrr�<module>s,&%X?�