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

Nj>@sdZddlmZddlZddlZddlmZddlmZm	Z	m
Z
mZmZddlm
Z
ddlZddlmZejjZededededd	Zd
ZGdddZGd
ddejZGdddejZedkrejdddS)zTest codecontext, coverage 100%)codecontextN)requires)NSEWTkFrameTextTclError)mock)config)mainZ	highlightkeys
extensionsz
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
c@s$eZdZddZddZddZdS)DummyEditwincCs"||_||_||_||_d|_dS)Nr)roottopZ
text_frametextlabel)selfrframerrG/opt/alt/python37/lib64/python3.7/idlelib/idle_test/test_codecontext.py__init__'s
zDummyEditwin.__init__cCstt|j|S)N)intfloatrindex)rrrrr	getlineno.szDummyEditwin.getlinenocKs|d|_dS)Nr)r)rkwargsrrrupdate_menu_label1szDummyEditwin.update_menu_labelN)__name__
__module____qualname__rrrrrrrr&src@seZdZeddZeddZddZddZd	d
ZddZ	d
dZ
ddZddZddZ
ddZddZejejdddZddZddZd S)!CodeContextTestcCs~tdt}|_|t|}|_t|}|_|dt	|j
dddd|jddtdt
||||_ttj_dS)NZguiz1.0leftZboth)ZsideZfillexpand)rowcolumnZsticky)rrrZwithdrawrrrrinsertcode_sampleZpackZgridrreditortestcfgridleConfuserCfg)clsrrrrrr
setUpClass7szCodeContextTest.setUpClasscCs@ttj_|jjdd|`|`|`|j	|j
|`dS)Nz1.0end)usercfgrr,r-r*rdeleterrZupdate_idletasksdestroy)r.rrr
tearDownClassEs

zCodeContextTest.tearDownClasscsjddjd<tj_ddd_tjjfdd}t	j
jtjd	|}|
|jd_fd
d}t	j
jtjd|}|
|jdS)
NrZTkFixedFontfontz#abcdefz#123456)
background
foregroundcs|dkrjS||S)Ncontext)
highlight_cfg)ZthemeZelement)orig_idleConf_GetHighlightrrrmock_idleconf_GetHighlightVsz9CodeContextTest.setUp.<locals>.mock_idleconf_GetHighlightGetHighlightcsjS)N)
font_override)rZ
configTypeZsection)rrrmock_idleconf_GetFont`sz4CodeContextTest.setUp.<locals>.mock_idleconf_GetFontZGetFont)ryviewrCodeContextr*ccr9r,r<unittestr	patchobjectstartZ
addCleanupstopr=)rr;ZGetHighlight_patcherr>ZGetFont_patcherr)r:rrsetUpNs"

zCodeContextTest.setUpcCs,|jjr|jj|j|j`|`dS)N)rAr8r3__del__)rrrrtearDowngs
zCodeContextTest.tearDowncCsz|j}|j}|j}||j|||j|j||jd|jd||j||jdg||jd||jj	dS)Nr5)rrFr$)
assertEqualr*rAeditwinrassertIsNoner8info
topvisiblet1)reqZedrArrr	test_initnszCodeContextTest.test_initcCs|jdS)N)rArH)rrrrtest_del{szCodeContextTest.test_delc	Csb|jddd}|j_|j|t}|jj	dd|WdQRX|
dt|jdS)Ni'cSsdS)Nrrrrr<lambda>z5CodeContextTest.test_del_with_timer.<locals>.<lambda>afterrNz
doesn't exist)
rrVrArPrHassertRaisesrrtkcallZassertInstrZ	exception)rtimercmrrrtest_del_with_timer~s

z#CodeContextTest.test_del_with_timercCstj||jjddS)N)rr@reloadrKrA
context_depth)rrrrtest_reloads
zCodeContextTest.test_reloadcCsJ|j}|j}|j}|jr||||j||jd|jd||jd|jd||jd|jd||jddd||jj	d	||j
jd
d|jj
dd
|||j||jj	d||jj
ddd|ddD}|jd|||jdd|||||jdd|dS)Nr5Zfgr7Zbgr6z1.0zend-1crzHide Code ContextrVrNr$r[zShow Code Context
css|]}|dVqdS)Nr).0xrrr	<genexpr>szACodeContextTest.test_toggle_code_context_event.<locals>.<genexpr>r)rKrAtoggle_code_context_eventr8ZassertIsNotNonerr9getrLrrrXrYrPrMjoinget_contextr?)rrQrAZtoggleZline11_contextrrrtest_toggle_code_context_events0 z.CodeContextTest.test_toggle_code_context_eventc	Cs.|j}|jj}|t|dddWdQRX||ddgdf||ddgdf||dddgdf||d	dd
dgdf||ddd
dd
gdf||ddddd
dd
gdf||dddd
dd
gdf||ddddd
gdf||dddd
dd
gdf||ddddd
gdfdS)Nr$r)Zstopline)rcrzclass C1():class)roroz    def __init__(self, a, b):def
)roz    def compare(self):rq)rtz        if a > b:ifrg)rrrtz        elif a < b:elifrcrt)Z
stopindent)rKrArkrWAssertionError)rrQZgcrrrtest_get_contexts:


z CodeContextTest.test_get_contextcCs*|j}|j}|js|||||jdg||jd|j	d|||jdg||jd||j
ddd|j	d|||jddg||jd||j
ddd	|j	d|||jddg||jd
||j
ddd	|j	d
|||jdddg||jd||j
ddd
|j	d|||jdddddg||jd||j
ddd|d|_||jdddddg||jd||j
ddd|j	d|||jdddg||jd||j
ddddS)N)rrJrFr$rcz1.0zend-1cr)rcrzclass C1():rnrmzclass C1():ro)roroz    def __init__(self, a, b):rqrpz)class C1():
    def __init__(self, a, b):rg)rsroz    def compare(self):rq)rtrtz        if a > b:ru)rrrtz        elif a < b:rvzHclass C1():
    def compare(self):
        if a > b:
        elif a < b:z    def __init__(self, a, b):)rKrAr8rhrMupdate_code_contextrNrOrr?rir`)rrQrArrrtest_update_code_contextslz(CodeContextTest.test_update_code_contextcCs.|j}|j}|j}|js ||jd|||jd|j	dd|||jd|jd|||jd|j	dd|||jd	d|_
|jd|||jd|j	dd
|||jd	|jd||jdd
d|j	dd
|||jd
dS)Nz2.0rcr(z1.5r$z12.0ryz3.0rtz1.0z5.0Zselrp)rKrAZ
jumptoliner8rhrr?r{rOZmark_setr`Ztag_add)rrQrAZjumprrrtest_jumptoline.s<zCodeContextTest.test_jumptoliner{cCsD|jjr|j|j||j|j|dS)N)rAr8rhZtimer_eventZassert_not_calledZ
assert_called)rZmock_updaterrrtest_timer_eventWs



z CodeContextTest.test_timer_eventcCs|j}|j}|jd}d}||||jdk	r8|||_||||jd|||_|||jd|dS)Nr5Z
TkTextFont)rKrArZassertNotEqualr8rhr=Zupdate_font)rrQrAZ	orig_font	test_fontrrrrds

zCodeContextTest.test_fontcs|j|jt|j}ddd}fdd}jr<||_||||||_||dS)Nz#222222z#ffff00)r6r7cs,jd|djd|ddS)Nr6r7)r8)Zcolors)rArQrrassert_colors_are_equalszFCodeContextTest.test_highlight_colors.<locals>.assert_colors_are_equal)rKrAdictr9r8rhZupdate_highlight_colors)rZorig_colorsZtest_colorsrr)rArQrtest_highlight_colors}s 

z%CodeContextTest.test_highlight_colorsN)rr r!classmethodr/r4rGrIrRrSr]rarlrxr|r}r	rCrDrr@r~rrrrrrr"5s	
$0Q)
r"c@seZdZddZddZdS)HelperFunctionTextcCsJtj}d}x |D]\}}||||qW||dtddddS)N))z    first word)z    first)z	first word)	r)u
  ᧔᧒: )z  u᧔᧒)z	no spaces)rZno)r)rr)z# TEST COMMENT)rr)z    (continuation))z    rz    (continuation)z^(\s*)([^\s]*))c)z    z(continuation))rZget_spaces_firstwordrKrecompile)rriZ
test_lineslineZexpected_outputrrrtest_get_spaces_firstwordsz,HelperFunctionText.test_get_spaces_firstwordcCs|j}tj}t}|||dtjddf|||dd|||dtjddf|||dd	|||d
d||dd
dS)NrrFr$)rzclass C1():rnrcz    # Class comment.rm)roz    def __init__(self, a, b):rqrs)rtz        if a > b:ruz	if a == b:)r$z	if a == b:ru)rKrZ
get_line_infor)
splitlinesZINFINITY)rrQZglilinesrrrtest_get_line_infosz%HelperFunctionText.test_get_line_infoN)rr r!rrrrrrrsr__main__rc)	verbosity)__doc__ZidlelibrrBZ
unittest.mockZtest.supportrZtkinterrrrrrr	rr
r,r-r1ZIdleUserConfParserr+r)rZTestCaser"rrrrrrr<module>s*k(