• File: test_format.cpython-37.opt-2.pyc
  • Full Path: /home3/farmfre2/public_html/ALFA_DATA/alfasymlink/root/opt/alt/python37/lib64/python3.7/idlelib/idle_test/__pycache__/test_format.cpython-37.opt-2.pyc
  • Date Modified: 10/26/2026 8:08 PM
  • File size: 19.02 KB
  • MIME-type: text/x-bytecode.python
  • Charset: 8 bit
B

YI~d<\@s<ddlmZddlZddlmZddlmZddlmZm	Z	ddl
mZddlm
ZGdd	d	ejZGd
ddejZGdd
d
ejZGdddejZGdddejZGdddZGdddZ
GdddejZGdddZGdddejZGdddejZGdddejZed kr8ejd!d!d"dS)#)formatN)mock)requires)TkText)EditorWindow)Editorc@s8eZdZdZdZdZdZdZddZdd	Z	d
dZ
dS)
Is_Get_Testz# This is a commentzThis is not a commentz# This is a comment   z    # This is a commentz    This is not a commentcCs6|td|td|t|jdS)Nz	

)Z
assertTrueftZis_all_whiteZassertFalsetest_comment)selfrB/opt/alt/python37/lib64/python3.7/idlelib/idle_test/test_format.pytest_is_all_whiteszIs_Get_Test.test_is_all_whitecCsR|j}|t|jd|t|jd|t|jd|t|jddS)Nr
z    )assertEqualrZ
get_indentrtrailingws_commentleadingws_commentleadingws_nocomment)r
Equalrrrtest_get_indents
zIs_Get_Test.test_get_indentcCsd|j}|t|jd|t|jd|t|jd|t|jd|t|jddS)N#z    #z    r
)rrZget_comment_headerrrrrtest_nocomment)r
rrrrtest_get_comment_header sz#Is_Get_Test.test_get_comment_headerN)__name__
__module____qualname__rrrrrrrrrrrrr	sr	c@s0eZdZeddZddZddZddZd	S)
FindTestcCsddlm}||_dS)Nr)r)Zidlelib.idle_test.mock_tkrtext)clsrrrr
setUpClass5szFindTest.setUpClassc	Cs|j}|d|xftd|D]X}t|d|dd}x6d|d|fD]$}d||f}|t|||qNWqW|	dddS)	Nz1.0z%d.end.rz%d.%dend)
rinsertrangeintindexsplitrrZfind_paragraphdelete)	r
Z
inserttextZstoplineexpectedrlineZ
linelengthcolZ	tempindexrrrruncase:szFindTest.runcasec
Csd}||dddd|ddfd}||d	d
dd|dd
fd}||d	d
dd|ddfd}||dd
dd|ddfd}||dd
dd|ddfd}||dd
dd|ddfd}||dd
dd|ddfd}||dd
dd|ddfdS)Nz;# Comment block with no blank lines before
# Comment line

z1.0z3.0rr:zG
# Comment block with whitespace line before and after
# Comment line

z2.0z4.0r!FzS
    # Indented comment block with whitespace before and after
    # Comment line

z    #Rz
# Single line comment

z4
    # Single line comment with leading whitespace

3z0
# Comment immediately followed by code
x = 42

(z=
    # Indented comment immediately followed by code
x = 42

5z=
# Comment immediately followed by indented code
    x = 42

1)r.)r
commentrrrtest_find_commentGs zFindTest.test_find_commentc
Csd}||dddd|ddfd}||d	d
dd|dd
fd}||d	d
dd|ddfd}||dd
dd|ddfd}||dd
dd|ddfdS)Nz6"""String with no blank lines before
String line
"""

r1z1.0z4.0r
rr7zC
"""String with whitespace line before and after
String line.
"""

z2.0z5.0r!BzV
    """Indented string with whitespace before and after
    Comment string.
    """

z    Uz
"""Single line string."""

r/z3.0z8
    """Single line string with leading whitespace."""

7)r.)r
Z
teststringrrrtest_find_paragraph}szFindTest.test_find_paragraphN)rrrclassmethodr r.r:r@rrrrr+s

6rc@seZdZddZdS)ReformatFunctionTestcCs|j}tj}d}||ddd||ddd|||dd|||dd|||d	d
|||dd
|||ddd
}|||dd|||dd|||d	d|||dd|||dd
dS)Nz
O hello world r!zHello    worldzHello  worldz
O
hello
worldz
O hello
world
z
O hello worldz
O
hello
worldz
O hello
world)rrZreformat_paragraph)r
rZreformZhwrrrtest_reformat_paragraphs z,ReformatFunctionTest.test_reformat_paragraphN)rrrrIrrrrrBsrBc@seZdZddZdS)ReformatCommentTestcCsJ|j}d}t|dd}d}|||d}t|dd}d}|||dS)Nzu    """this is a test of a reformat for a triple quoted string will it reformat to less than 70 characters for me?"""r2z    zy    """this is a test of a reformat for a triple quoted string will it
    reformat to less than 70 characters for me?"""zm# this is a test of a reformat for a triple quoted string will it reformat to less than 70 characters for me?rzo# this is a test of a reformat for a triple quoted string will it
# reformat to less than 70 characters for me?)rrZreformat_comment)r
rtest_stringresultr+rrrrtest_reformat_comments
z)ReformatCommentTest.test_reformat_commentN)rrrrMrrrrrJsrJc@seZdZddZdS)FormatClassTestcCs2td}||jd|||jddS)Neditor)rFormatParagraphrZeditwinclose)r
instancerrrtest_init_closes
zFormatClassTest.test_init_closeN)rrrrSrrrrrNsrNc@s,eZdZddZddZddZddZd	S)
TextWrappercCst|d|_dS)N)master)rr)r
rUrrr__init__szTextWrapper.__init__cCst|j|S)N)getattrr)r
namerrr__getattr__szTextWrapper.__getattr__cCsdS)Nr)r
rrrundo_block_startzTextWrapper.undo_block_startcCsdS)Nr)r
rrrundo_block_stopr[zTextWrapper.undo_block_stopN)rrrrVrYrZr\rrrrrTsrTc@seZdZddZejZdS)rcCst||_dS)N)rTr)r
rootrrrrVszEditor.__init__N)rrrrVrget_selection_indicesrrrrrsrc@sPeZdZdZdZdZeddZeddZdd	Z	d
dZ
dd
ZddZdS)FormatEventTestzv    '''this is a test of a reformat for a triple quoted string will it reformat to less than 70 characters for me?'''
a    '''The first line is under the max width.
    The second line's length is way over the max width. It goes on and on until it is over 100 characters long.
    Same thing with the third line. It is also way over the max width, but FormatParagraph will fix it.
    '''
a,# The first line is under the max width.
# The second line's length is way over the max width. It goes on and on until it is over 100 characters long.
# Same thing with the third line. It is also way over the max width, but FormatParagraph will fix it.
# The fourth line is short like the first line.cCsBtdt|_|jt|jd}|jj|_t|j|_	dS)Ngui)r])
rrr]withdrawrrrrPZformat_paragraph_event	formatter)rrOrrrr s

zFormatEventTest.setUpClasscCs$|`|`|j|j|`dS)N)rrbr]update_idletasksdestroy)rrrr
tearDownClasss

zFormatEventTest.tearDownClasscCs@|jdd|d||jddd|jdddS)Nz1.0zShort line
ZDummyr%r$)rr%rbrgetr*)r
rrrtest_short_line s
zFormatEventTest.test_short_linecCs|j}|d|j|dd|jddd|dd}d}||||dd|d|j|dd	d
|jddd|dd}d}||||dddS)Nz1.0r%ParameterDoesNothingr2)limitzz    '''this is a test of a reformat for a triple quoted string will it
    reformat to less than 70 characters for me?'''
r$selz1.11z1.endzv    '''this is a test of a reformat for a triple quoted string will it reformat
 to less than 70 characters for me?''')	rr%rKZmark_setrbrfrr*tag_add)r
rrLr+rrrtest_long_line&szFormatEventTest.test_long_linecCs\|j}|d|j|ddd|jddd|dd}d	}||||dd
dS)Nz1.0rjz2.0z4.0rhr2)rir%z    The second line's length is way over the max width. It goes on and
    on until it is over 100 characters long. Same thing with the third
    line. It is also way over the max width, but FormatParagraph will
    fix it.
r$)rr%multiline_test_stringrkrbrfrr*)r
rrLr+rrrtest_multiple_linesAsz#FormatEventTest.test_multiple_linescCs|j}|d|j|jddd|dd}d}||||dd|d|j|dd	d
|jddd|dd}d}||||dddS)Nz1.0rhr2)rir%a/# The first line is under the max width. The second line's length is
# way over the max width. It goes on and on until it is over 100
# characters long. Same thing with the third line. It is also way over
# the max width, but FormatParagraph will fix it. The fourth line is
# short like the first line.
r$rjz2.0z3.0z# The first line is under the max width.
# The second line's length is way over the max width. It goes on and
# on until it is over 100 characters long.
)rr%multiline_test_commentrbrfrr*rk)r
rrLr+rrrtest_comment_blockPsz"FormatEventTest.test_comment_blockN)
rrrrKrmrorAr rergrlrnrprrrrr_s
r_c@s eZdZddZejZejZdS)DummyEditwincCs(||_||_d|_d|_d|_d|_dS)Nr1FT)r]rindentwidthZtabwidthusetabsZcontext_use_ps1)r
r]rrrrrV}szDummyEditwin.__init__N)rrrrVrZ_make_blanksr^rrrrrq|srqc@seZdZeddZeddZddZddZd	Zd
dZ	dd
Z
ddZddZddZ
ddZejejdddZejejdddZejedddZdS)FormatRegionTestcCs`tdt|_|jt|j|_t|j_t|j_	t
|j|j|_t
|j|_dS)Nr`)rrr]rarrrMockrZr\rqrOrFormatRegionrb)rrrrr s
zFormatRegionTest.setUpClasscCs(|`|`|`|j|j|`dS)N)rrbrOr]rcrd)rrrrres

zFormatRegionTest.tearDownClasscCs|jd|jdS)Nz1.0)rr%code_sample)r
rrrsetUpszFormatRegionTest.setUpcCs|jdddS)Nz1.0r$)rr*)r
rrrtearDownszFormatRegionTest.tearDowna# WS line needed for test.
class C1():
    # Class comment.
    def __init__(self, a, b):
        self.a = a
        self.b = b

    def compare(self):
        if a > b:
            return a
        elif a < b:
            return b
        else:
            return None
cCsr|jj}|j}|j}|dddddddg}||ddd||f|ddd	||d
ddddgfdS)Nrjz7.0z10.0r
z    def compare(self):z        if a > b:
z1.0r$z15.0z16.0)rb
get_regionrrrkjoin
tag_remove)r
rfreqZexpected_linesrrrtest_get_regionsz FormatRegionTest.test_get_regionc
Cs&|jj}|j}|j}|j}t|_|jd}|jd}|	ddd|j
\}}}	}
||||	|
|j||dd|	||dd|	|
ddd	d
}|d}|dd
|	|||dd|||dd|||dd|||dd||
ddd	||_dS)Nr;	rjz6.0z11.0z	sel.firstzsel.lastz1.0r$zadded line 1



rzz7.0z10.0z7.0-1cz12.0-1c)rb
set_regionrrZbellrrurw
splitlinesrkr{Zassert_called_oncerfr}r))
r
Zset_rr~Z	save_bellZline6Zline10headtailcharslinesZ	newstringnewlinesrrrtest_set_regions.


z FormatRegionTest.test_set_regioncCs>|jj}|j}|j}|ddd|||ddddS)Nrjz7.0z10.0z2
        def compare(self):
            if a > b:
)rbZindent_region_eventrrrkrf)r
indentrr~rrrtest_indent_region_eventsz)FormatRegionTest.test_indent_region_eventcCs>|jj}|j}|j}|ddd|||ddddS)Nrjz7.0z10.0z"
def compare(self):
    if a > b:
)rbZdedent_region_eventrrrkrf)r
dedentrr~rrrtest_dedent_region_eventsz)FormatRegionTest.test_dedent_region_eventcCs>|jj}|j}|j}|ddd|||ddddS)Nrjz7.0z10.0z0##
##    def compare(self):
##        if a > b:
)rbcomment_region_eventrrrkrf)r
r9rr~rrrtest_comment_region_eventsz*FormatRegionTest.test_comment_region_eventcCs|jj}|jj}|j}|j}|ddd||||ddd|ddd|ddd|||dd	d
|jdddddg|||dd	d
dS)Nrjz7.0z10.0z*
    def compare(self):
        if a > b:
z1.0r$z3.0z4.0z3.endz    # Class comment.r
z# Class comment.z Class comment.)	rbrZuncomment_region_eventrrrkrfr}r)r
r9Z	uncommentrr~rrrtest_uncomment_region_eventsz,FormatRegionTest.test_uncomment_region_event_asktabwidthcCs\|jj}|j}|j}|dddd|_||d|_||||ddddS)Nrjz7.0z10.0r/z$
	 def compare(self):
		  if a > b:
)	rbtabify_region_eventrrrkreturn_valueassertIsNoneassertIsNotNonerf)r
rZtabifyrr~rrrtest_tabify_region_eventsz)FormatRegionTest.test_tabify_region_eventcCsl|jj}|j}|j}|dddd|_||d|_|jd|_||||	ddddS)Nrjz7.0z10.0r#r/z0
      def compare(self):
            if a > b:
)
rbZuntabify_region_eventrrrkrrrrrf)r
rZuntabifyrr~rrrtest_untabify_region_event)s
z+FormatRegionTest.test_untabify_region_event
askintegercCs |jj}d|_||ddS)N
)rbrrr)r
rZaskrrrtest_ask_tabwidth:sz"FormatRegionTest.test_ask_tabwidthN)rrrrAr rerxryrwrrrrrrrpatchobjectrrvrrrrrrrrts#

	rtc@s8eZdZejedddZejedddZdS)IndentsTestaskyesnocCsjtdd}t|}d|_|d||jd||jd|d||jd||jddS)NTF)rqrIndentsrZtoggle_tabs_eventrrsrr)r
rrOindentsrrrtest_toggle_tabsCs



zIndentsTest.test_toggle_tabsrcCsxtdd}t|}d|_|d||jdd|_|d||jdd|_d|_|d||jddS)Nr1r/r;T)rqrrrZchange_indentwidth_eventrrrrs)r
rrOrrrrtest_change_indentwidthQs




z#IndentsTest.test_change_indentwidthN)	rrrrrrrrrrrrrrAsrc@s<eZdZeddZeddZddZddZd	d
ZdS)
RstripTestcCsHtdt|_|jt|j|_t|jd|_t	|jj
|_
dS)Nr`)r)rrr]rarr
MockEditorrOrZRstrip	do_rstrip)rrrrr fs
zRstripTest.setUpClasscCs(|`|`|`|j|j|`dS)N)rrrOr]rcrd)rrrrreos

zRstripTest.tearDownClasscCs|jdddS)Nz1.0zend-1c)rr*)r
rrrryvszRstripTest.tearDowncCs8d}d}|jd||||jdd|dS)NzLine with an ending tab    
Line ending in 5 spaces     
Linewithnospaces
    indented line
    indented line with trailing space 
    
zyLine with an ending tab
Line ending in 5 spaces
Linewithnospaces
    indented line
    indented line with trailing space
z1.0r%)rr%rrrf)r
Zoriginalstrippedrrrtest_rstrip_linesys
zRstripTest.test_rstrip_linesc
Cs|j}xLdD]D}|j|d.|d||||dddWdQRXqWxXdD]P}|j|d:|dd|d||||dddWdQRXqZWdS)N)r
rzz


)codez1.0zend-1cr
)za
za

za


za
)rZsubTestr%rrrfr*)r
rrrrrtest_rstrip_ends
"
zRstripTest.test_rstrip_endN)	rrrrAr reryrrrrrrrds
	r__main__r#)	verbosityexit)ZidlelibrrZunittestrZtest.supportrZtkinterrrZidlelib.editorrZidlelib.idle_test.mock_idlerrZTestCaser	rrBrJrNrTr_rqrtrrrmainrrrr<module>s,w
9#7