3  f8@sdZddlmZddlZddlmZddlmZmZm Z m Z ddlm Z ddl Z ddlm Z ejjZe jde jde jde jdd Zd ZGd d d ZGd ddejZGdddejZedkrejdddS)zTest codecontext, coverage 100%) codecontextN)requires)TkFrameTextTclError)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@seZdZddZdS) DummyEditwincCs||_||_||_||_dS)N)roottopZ text_frametext)selfrframerrG/opt/alt/python36/lib64/python3.6/idlelib/idle_test/test_codecontext.py__init__&szDummyEditwin.__init__N)__name__ __module__ __qualname__rrrrrr%src@seZdZeddZeddZddZddZd d Zd d Z d dZ ddZ ddZ ddZ ddZejjejdddZddZdS)CodeContextTestcCs~tdt}|_|jt|}|_t|}|_|jdt |j dddd|j ddddt ||||_ t tj_dS)NZguiz1.0leftZboth)ZsideZfillexpandr)rrrZwithdrawrrrrinsert code_sampleZpackreditortestcfgridleConfuserCfg)clsrrrrrr setUpClass/s  zCodeContextTest.setUpClasscCs@ttj_|jjjdd|`|`|`|jj |jj |`dS)Nz1.0end) usercfgrr"r#r rdeleterrZupdate_idletasksdestroy)r$rrr tearDownClass=s    zCodeContextTest.tearDownClasscCs|jjdtj|j|_dS)Nr)ryviewr CodeContextr cc)rrrrsetUpFs zCodeContextTest.setUpcCs,|jjr|jjj|jj|j`|`dS)N)r-contextr)__del__)rrrrtearDownJs  zCodeContextTest.tearDowncCs|j}|j}|j}||j|||j|j||j|jd|j|j||jd g||j d||j j j dd|jj dd||j j j dd|jjdddS) Nfontrrr FafterinfoZtimer)rr5r F) assertEqualr r-Zeditwinrtextfont assertIsNoner/r4 topvisiblertkcallt1t2)reqZedr-rrr test_initQs    zCodeContextTest.test_initcCs|jj|jt(}|jjjdd|jj|jd|WdQRX|jt(}|jjjdd|jj |jd|WdQRX|j`|j` |jjdS)Nr3r4z doesn't exist) r-r0 assertRaisesrrr:r;r<ZassertInr=)rmsgrrrtest_del_s    zCodeContextTest.test_delcCs4tjj|j|jjddd|j|jjddS)NZ lightgrayz#000000) background foreground)rr,reloadr6r-colors context_depth)rrrr test_reloadls   zCodeContextTest.test_reloadcCs|j}|j}|j}|jr|||d|j|j||jd|j||jd|jd||jd|jd||jjddd ||d|j|jdS) Nbreakr2ZfgrDZbgrCz1.0zend-1cr ) r6r-toggle_code_context_eventr/ZassertIsNotNoner7rGgetr8)rr>r-Ztogglerrrtest_toggle_code_context_eventrs   z.CodeContextTest.test_toggle_code_context_eventcCs.|j}|jj}|jt|dddWdQRX||ddgdf||ddgdf||d ddgdf||d dddgdf||ddddd gdf||dddd!d"d#d$gdf||dddd%d&d'gdf||dddd(d)gdf||dddd*d+d,gdf||dddd-d.gdfdS)/Nrr)Zstopline class C1():class def __init__(self, a, b):def  def compare(self): if a > b:if  elif a < b:elif)Z stopindent)rOrrPrQ)rOrrPrQ)rOrrPrQ)rRrRrTrU)rOrrPrQ)rWrRrXrU)rYrYrZr[)rOrrPrQ)rWrRrXrU)rYrYrZr[)rVrYr]r^)rOrrPrQ)rWrRrXrU)rYrYrZr[)rVrYr]r^)rWrRrXrU)rYrYrZr[)rVrYr]r^)rYrYrZr[)rVrYr]r^)rWrRrXrU)rYrYrZr[)rVrYr]r^)rYrYrZr[)rVrYr]r^)r6r-Z get_contextr@AssertionError)rr>gcrrrtest_get_contexts:           z CodeContextTest.test_get_contextc Cs*|j}|j}|js|j|j|j||jdg||jd|jj d|j||jdg||jd||jj ddd|jj d|j||jd!d"g||jd ||jj ddd|jj d |j||jd$d%g||jd ||jj ddd|jj d |j||jd'd(d)g||jd||jj ddd|jj d|j||jd+d,d-d.d/g||jd||jj ddd|jd|_ ||jd1d2d3d4d5g||jd||jj ddd|jj d|j||jd7d8d9g||jd||jj ddd dS):Nrrr FrOz1.0zend-1c class C1():rQrNrR def __init__(self, a, b):rUrSz)class C1(): def __init__(self, a, b):r\rW def compare(self):rY if a > b:r[rV elif a < b:r^ zHclass C1(): def compare(self): if a > b: elif a < b:r5)rr5r Fr5)rr5r Fr5)rr5r F)rOrrbrQr5)rr5r F)rOrrbrQr5)rr5r F)rOrrbrQ)rRrRrcrUr5)rr5r F)rOrrbrQ)rWrRrdrU)rYrYrer[)rVrYrfr^r5)rr5r F)rOrrbrQ)rWrRrdrU)rYrYrer[)rVrYrfr^r5)rr5r F)rOrrbrQ)rRrRrcrU) r6r-r/rKr8update_code_contextr4r9rr+rLrH)rr>r-rrrtest_update_code_contextsl              z(CodeContextTest.test_update_code_contextcCs|j}|j}|j}|js |j|jjdd|j||jd|jj dd|||jd|jjdd|j||jd|jj dd|||jdd|_ |jjdd|j||jd|jj dd |||jddS) NrOz.0rz1.5rrgz3.0rYz1.0) r6r-Z jumptoliner/rKrr+rir9Zmark_setrH)rr>r-Zjumprrrtest_jumptolines0     zCodeContextTest.test_jumptolinericCsD|jjr|jj|jj|j|jj|jj|jdS)N)r-r/rKZ timer_eventZassert_not_calledZ assert_called)rZ mock_updaterrrtest_timer_event)s    z CodeContextTest.test_timer_eventcCs|j}|j}|jd}tjj}d}ddd}|jr:|j||jd<|tj_|j||j |||j ||j||jd<|tj_|j||j |||j |||jd|||jd|d||jd|d||jd<|j||j |||j |||jd|||jd|d||jd|d||jd<|tj_|j||j |||j |||jd|||jd|d||jd|d|tj_|jdS)Nr2ZFakeFontz#222222z#ffff00)rCrDrCrD) r6r-rrr,rGr/rKZconfig_timer_eventr7Z contextcolors)rr>r-Z save_fontZ save_colorsZ test_fontZ test_colorsrrrtest_config_timer_event6sN              z'CodeContextTest.test_config_timer_eventN)rrr classmethodr%r*r.r1r?rBrIrMrarjrkrZpatchobjectrr,rlrmrrrrr-s   0Q! rc@seZdZddZddZdS)HelperFunctionTextc CsJtj}d}x |D]\}}|j|||qW|j|d tjddd dS)!N first word first first word ᧔᧒:  ᧔᧒ no spacesr no# TEST COMMENT (continuation)z^(\s*)([^\s]*))c(continuation)rrrsrqrrursrtrrwrxrvrr rzryrr r r rr r r{rrrr r|r)rrrrrrr)rrr~)rZget_spaces_firstwordr6recompile)rrLZ test_lineslineZexpected_outputrrrtest_get_spaces_firstwordls z,HelperFunctionText.test_get_spaces_firstwordcCs|j}tj}tj}|||dtjddf|||dd|||dtjddf|||d d|||d d||dddS)Nrr Fr class C1():rQrOz # Class comment.rNrR def __init__(self, a, b):rUrWrY if a > b:r[ if a == b:)rrrQ)rRrrU)rYrr[)rrr[)r6rZ get_line_infor splitlinesZINFINITY)rr>Zglilinesrrrtest_get_line_infosz%HelperFunctionText.test_get_line_infoN)rrrrrrrrrrpjsrp__main__rO) verbosity)__doc__ZidlelibrZunittestZ test.supportrZtkinterrrrrrrr r"r#r'ZIdleUserConfParserr!rrZTestCaserrprr rrrrs(    ?(