3 2a8@sddlmZddlZddlmZddlmZmZmZm Z ddlm Z ddl Z ddlm Z ej jZe jde jde jde jddZd ZGd d d ZGd d d ejZGdddejZedkrejdddS)) 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)selfrframerr5/opt/alt/python36/lib64/python3.6/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)Zsidefillexpandr)rrrZwithdrawrrrrinsert code_samplepackreditortestcfgridleConfuserCfg)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)rr7r F) assertEqualr"r/Zeditwinrtextfont assertIsNoner1r6 topvisiblertkcallt1t2)reqZedr/rrr test_initQs    zCodeContextTest.test_initcCs|jj|jt(}|jjjdd|jj|jd|WdQRX|jt(}|jjjdd|jj |jd|WdQRX|j`|j` |jjdS)Nr5r6z doesn't exist) r/r2 assertRaisesrrr<r=r>ZassertInr?)rmsgrrrtest_del_s    zCodeContextTest.test_delcCs4tjj|j|jjddd|j|jjddS)NZ lightgrayz#000000) background foreground)rr.reloadr8r/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) Nbreakr4ZfgrFbgrEz1.0zend-1cr ) r8r/toggle_code_context_eventr1ZassertIsNotNoner9rIgetr:)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)rRrrSrT)rRrrSrT)rRrrSrT)rUrUrWrX)rRrrSrT)rZrUr[rX)r\r\r]r^)rRrrSrT)rZrUr[rX)r\r\r]r^)rYr\r`ra)rRrrSrT)rZrUr[rX)r\r\r]r^)rYr\r`ra)rZrUr[rX)r\r\r]r^)rYr\r`ra)r\r\r]r^)rYr\r`ra)rZrUr[rX)r\r\r]r^)rYr\r`ra)r\r\r]r^)rYr\r`ra)r8r/Z get_contextrBAssertionError)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 FrRz1.0zend-1c class C1():rTrQrU def __init__(self, a, b):rXrVz)class C1(): def __init__(self, a, b):r_rZ def compare(self):r\ if a > b:r^rY elif a < b:ra zHclass C1(): def compare(self): if a > b: elif a < b:r7)rr7r Fr7)rr7r Fr7)rr7r F)rRrrerTr7)rr7r F)rRrrerTr7)rr7r F)rRrrerT)rUrUrfrXr7)rr7r F)rRrrerT)rZrUrgrX)r\r\rhr^)rYr\rirar7)rr7r F)rRrrerT)rZrUrgrX)r\r\rhr^)rYr\rirar7)rr7r F)rRrrerT)rUrUrfrX) r8r/r1rNr:update_code_contextr6r;rr-rOrJ)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) NrRz.0rz1.5rrjz3.0r\z1.0) r8r/Z jumptoliner1rNrr-rlr;Zmark_setrJ)rr@r/Zjumprrrtest_jumptolines0     zCodeContextTest.test_jumptolinerlcCsD|jjr|jj|jj|j|jj|jj|jdS)N)r/r1rNZ 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)Nr4ZFakeFontz#222222z#ffff00)rErFrErF) r8r/rrr.rIr1rNZconfig_timer_eventr9Z contextcolors)rr@r/Z save_fontZ save_colorsZ test_fontZ test_colorsrrrtest_config_timer_event6sN              z'CodeContextTest.test_config_timer_eventN)rrr classmethodr'r,r0r3rArDrKrPrdrmrnrZpatchobjectrr.rorprrrrr-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)rurvrtrrxrvrwrrzr{ryrr r}r|rr r r rr r r~rrur rr)rrrrrrr)rur)rZget_spaces_firstwordr8recompile)rrOZ 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():rTrRz # Class comment.rQrU def __init__(self, a, b):rXrZr\ if a > b:r^ if a == b:)rrrT)rUrrX)r\rr^)rrr^)r8rZ get_line_infor splitlinesZINFINITY)rr@Zglilinesrrrtest_get_line_infosz%HelperFunctionText.test_get_line_infoN)rrrrrrrrrrsjsrs__main__rR) verbosity)ZidlelibrZunittestZ test.supportrZtkinterrrrrrrr r$r%r)ZIdleUserConfParserr#r rZTestCaserrsrr rrrrs&    ?(