Your IP : 216.73.216.213


Current Path : /proc/242857/root/opt/alt/python34/lib64/python3.4/test/__pycache__/
Upload File :
Current File : //proc/242857/root/opt/alt/python34/lib64/python3.4/test/__pycache__/test_difflib.cpython-34.pyo

�
g f�/�@s&ddlZddlmZmZddlZddlZddlZGdd�dej�ZGdd�dej�Z	Gdd�dej�Z
d	Zd
ZdZ
dZd
ZdZGdd�dej�ZGdd�dej�ZGdd�dej�Zdd�Zedkr"e�ndS)�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)�insertrrrr)rrrrr
)rrrrr)rrrrr)rrrrr
)	�difflib�SequenceMatcher�assertAlmostEqual�ratio�assertEqual�list�get_opcodes�bpopular�set)�self�sm�r�6/opt/alt/python34/lib64/python3.4/test/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)�equalrrrr)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@s"eZdZdZdd�ZdS)�TestAutojunkz-Tests for the autojunk parameter added in 2.7cCs�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/�__doc__r2rrrrr0.sr0c@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_opcodesZ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)rr5�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 bugr;z? +
r	)rrZDifferZcomparer)rZdiffrrr�test_added_tab_hintXs
$zTestSFbugs.test_added_tab_hintN)r-r.r/r6r:r?r@rrrrr4@s	r4z�
   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.
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@s(eZdZdd�Zdd�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��WdQXdS)#Nz123
�
r	z456
�tabsizer;Z
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�HtmlDiffZ	make_file�joinZ
make_table�replace�openrr�read)rZf1aZt1aZf1bZt1b�f2Zt2Zf3Zt3�i�j�k�fullZtablesZactual�fprrr�test_html_diff�s\$!!'*zTestSFpatches.test_html_diffcCsctj�}dd�t|d�D�}dd�t|d�D�}tjd||�j�dS)NcSs*g|] }|drdpd|�qS)r;zK:%dzV:A:%dr)�.0rWrrr�
<listcomp>�s	z6TestSFpatches.test_recursion_limit.<locals>.<listcomp>r;cSs*g|] }|drdpd|�qS)r;zK:%dzV:B:%dr)r]rWrrrr^�s	)�sys�getrecursionlimit�rangerrr)r�limit�old�newrrr�test_recursion_limit�sz"TestSFpatches.test_recursion_limitN)r-r.r/r\rerrrrrA�s9rAc@s@eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�TestOutputFormatcCs�ddddddg}tjdd|�}|jt|�d	d
�ddg�tjdd|�}|jt|�d	d
�d
dg�dS)N�one�two�Original�Currentz2005-01-26 23:30:50z2010-04-02 10:20:52�lineterm�rr;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:52)rr9rr�context_diff)r�args�ud�cdrrr�test_tab_delimiter�s
z#TestOutputFormat.test_tab_delimitercCs�ddddg}tjdd|�}|jt|�dd�d	d
g�tjdd|�}|jt|�dd�ddg�dS)
Nrgrhrirjrkrlrr;z--- Originalz+++ Currentz*** Originalz--- Current)rr9rrrm)rrnrorprrr�&test_no_trailing_tab_on_empty_filedate�s
&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��4rGz4,2rIz4,3rz0,0)rZ_format_range_unifiedr)r�spec�fmtrrr�test_range_format_unified�s		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	�3rsrtrGz4,5rIz4,6r�0)rZ_format_range_contextr)rrurvrrr�test_range_format_context	s	z*TestOutputFormat.test_range_format_contextN)r-r.r/rqrrrwrzrrrrrf�srfc@sLeZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)�TestJunkAPIscCsFx?ddddddgD]%}|jtj|�t|��qWdS)N�#z  z #z# z # rl)�
assertTruer�IS_LINE_JUNK�repr)r�linerrr�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|rH��
�)r�rr�r)rr�rrr�test_is_character_junk_false2sz)TestJunkAPIs.test_is_character_junk_falseN)r-r.r/r�r�r�r�r�rrrrr{!s
r{cCs;dtj_tjt�}ttttt	t
t|�dS)Nr)rrQZ_default_prefix�doctestZDocTestSuiterrr0rAr4rfr{)ZDoctestsrrr�	test_main6s
r��__main__)rZtest.supportrrZunittestr�r_ZTestCaserr0r4rJrKrMrNrOrPrArfr{r�r-rrrr�<module>s&&%C>