ž pyMa’)c@sfdZGdd„dƒZGdd„dƒZGdd„dƒZddlmZGd d „d ƒZd S( uÉClasses that replace tkinter gui objects used by an object being tested. A gui object is anything with a master or parent paramenter, which is typically required in spite of what the doc strings say. cBsG|EeZdZdZddddd„Zdd„Zdd„ZdS( uVaru)Use for String/Int/BooleanVar: incompletecCs||_||_||_dS(N(umasteruvalueuname(uselfumasteruvalueuname((u>/opt/alt/python33/lib64/python3.3/idlelib/idle_test/mock_tk.pyu__init__ s  u Var.__init__cCs ||_dS(N(uvalue(uselfuvalue((u>/opt/alt/python33/lib64/python3.3/idlelib/idle_test/mock_tk.pyuset suVar.setcCs|jS(N(uvalue(uself((u>/opt/alt/python33/lib64/python3.3/idlelib/idle_test/mock_tk.pyugetsuVar.getN(u__name__u __module__u __qualname__u__doc__uNoneu__init__usetuget(u __locals__((u>/opt/alt/python33/lib64/python3.3/idlelib/idle_test/mock_tk.pyuVars uVarcBs2|EeZdZdZdd„Zdd„ZdS(u Mbox_funcuæGeneric mock for messagebox functions, which all have the same signature. Instead of displaying a message box, the mock's call method saves the arguments as instance attributes, which test functions can then examime. cCs d|_dS(N(uNoneuresult(uself((u>/opt/alt/python33/lib64/python3.3/idlelib/idle_test/mock_tk.pyu__init__suMbox_func.__init__cOs+||_||_||_||_|jS(N(utitleumessageuargsukwdsuresult(uselfutitleumessageuargsukwds((u>/opt/alt/python33/lib64/python3.3/idlelib/idle_test/mock_tk.pyu__call__s     uMbox_func.__call__N(u__name__u __module__u __qualname__u__doc__u__init__u__call__(u __locals__((u>/opt/alt/python33/lib64/python3.3/idlelib/idle_test/mock_tk.pyu Mbox_funcs u Mbox_funccBsb|EeZdZdZeƒZeƒZeƒZeƒZeƒZ eƒZ eƒZ eƒZ dS(uMboxu5Mock for tkinter.messagebox with an Mbox_func for each function. This module was 'tkMessageBox' in 2.x; hence the 'import as' in 3.x. Example usage in test_module.py for testing functions in module.py: --- from idlelib.idle_test.mock_tk import Mbox import module orig_mbox = module.tkMessageBox showerror = Mbox.showerror # example, for attribute access in test methods class Test(unittest.TestCase): @classmethod def setUpClass(cls): module.tkMessageBox = Mbox @classmethod def tearDownClass(cls): module.tkMessageBox = orig_mbox --- For 'ask' functions, set func.result return value before calling the method that uses the message function. When tkMessageBox functions are the only gui alls in a method, this replacement makes the method gui-free, N( u__name__u __module__u __qualname__u__doc__u Mbox_funcu askokcancelu askquestionuaskretrycanceluaskyesnouaskyesnocancelu showerrorushowinfou showwarning(u __locals__((u>/opt/alt/python33/lib64/python3.3/idlelib/idle_test/mock_tk.pyuMbox"s       uMboxi(uTclErrorcBsé|EeZdZdZd!idd„Zdd„Zddd„Zd d „Zd d „Z d!d d„Z d!dd„Z dd„Z dd„Z dd„Zd!dd„Zdd„Zdd„Zdd„Zd!d!d!dd „Zd!S("uTextuƒA semi-functional non-gui replacement for tkinter.Text text editors. The mock's data model is that a text is a list of -terminated lines. The mock adds an empty string at the beginning of the list so that the index of actual lines start at 1, as with Tk. The methods never see this. Tk initializes files with a terminal that cannot be deleted. It is invisible in the sense that one cannot move the cursor beyond it. This class is only tested (and valid) with strings of ascii chars. For testing, we are not concerned with Tk Text's treatment of, for instance, 0-width characters or character + accent. cKsddg|_dS(uÑInitialize mock, non-gui, text-only Text widget. At present, all args are ignored. Almost all affect visual behavior. There are just a few Text-only options that affect text behavior. uu N(udata(uselfumasterucnfukw((u>/opt/alt/python33/lib64/python3.3/idlelib/idle_test/mock_tk.pyu__init__Tsu Text.__init__cCsd|j|ddƒS(uAReturn string version of index decoded according to current text.u%s.%suendflagi(u_decode(uselfuindex((u>/opt/alt/python33/lib64/python3.3/idlelib/idle_test/mock_tk.pyuindex\su Text.indexic Csut|ttfƒr$t|ƒ}ny|jƒ}Wn%tk r[td|ƒd‚YnXt|j ƒd}|dkr–|t|j |ƒdfS|dkr¯|j |ƒS|j dƒ\}}t |ƒ}|dkràd S||krù|j |ƒSt|j |ƒd}|j dƒs+|dkr5||fSt |ƒ}|dkrVd}n||krk|}n||fS( u7Return a (line, char) tuple of int indexes into self.data. This implements .index without converting the result back to a string. The result is contrained by the number of lines and linelengths of self.data. For many indexes, the result is initially (1, 0). The input index may have any of several possible forms: * line.char float: converted to 'line.char' string; * 'line.char' string, where line and char are decimal integers; * 'line.char lineend', where lineend='lineend' (and char is ignored); * 'line.end', where end='end' (same as above); * 'insert', the positions before terminal ; * 'end', whose meaning depends on the endflag passed to ._endex. * 'sel.first' or 'sel.last', where sel is a tag -- not implemented. ubad text index "%s"iuinsertuendu.iu lineendN(ii(u isinstanceufloatubytesustruloweruAttributeErroruTclErroruNoneulenudatau_endexusplituintuendswith(uselfuindexuendflagulastlineulineucharu linelength((u>/opt/alt/python33/lib64/python3.3/idlelib/idle_test/mock_tk.pyu_decode`s4              u Text._decodecCsNt|jƒ}|dkr%|dfS|d8}|t|j|ƒ|fSdS(uReturn position for 'end' or line overflow corresponding to endflag. -1: position before terminal ; for .insert(), .delete 0: position after terminal ; for .get, .delete index 1 1: same viewed as beginning of non-existent next line (for .index) iiN(ulenudata(uselfuendflagun((u>/opt/alt/python33/lib64/python3.3/idlelib/idle_test/mock_tk.pyu_endex“s    u Text._endexcCsà|s dS|jdƒ}|dddkr=|jdƒn|j|d ƒ\}}|j|d|…}|j||d…}||d|j|<|dd…|j|d|d…<|j|t|ƒd|7/opt/alt/python33/lib64/python3.3/idlelib/idle_test/mock_tk.pyuinsert¢s%u Text.insertc Csæ|j|ƒ\}}|dkr5||d}}n|j|ƒ\}}||krk|j|||…S|j||d…g}x/t|d|ƒD]}|j|j|ƒq™W|j|j|d|…ƒdj|ƒSdS(u;Return slice from index1 to index2 (default is 'index1+1').iNu(u_decodeuNoneudataurangeuappendujoin( uselfuindex1uindex2u startlineu startcharuendlineuendcharulinesui((u>/opt/alt/python33/lib64/python3.3/idlelib/idle_test/mock_tk.pyuget²s  uText.getcCsg|j|dƒ\}}|dkr‰|t|j|ƒdkrU||d}}q¡|t|jƒdkr‚|dd}}q¡dSn|j|dƒ\}}||krï||krï|j|d|…|j||d…|j|/opt/alt/python33/lib64/python3.3/idlelib/idle_test/mock_tk.pyudeleteÅs" "  u Text.deletecCs:|j|ƒ\}}|j|ƒ\}}|dkrX||kpW||koW||kS|dkr†||kp…||ko…||kS|dkr´||kp³||ko³||kS|dkrâ||kpá||koá||kS|dkr||ko||kS|dkr&||kp%||kStd|ƒ‚dS(Nuu>=u==u!=u<bad comparison operator "%s":must be <, <=, ==, >=, >, or !=(u_decodeuTclError(uselfuindex1uopuindex2uline1uchar1uline2uchar2((u>/opt/alt/python33/lib64/python3.3/idlelib/idle_test/mock_tk.pyucompareäs  " " " "  u Text.comparecCsdS(u.Set mark *name* before the character at index.N((uselfunameuindex((u>/opt/alt/python33/lib64/python3.3/idlelib/idle_test/mock_tk.pyumark_setúsu Text.mark_setcGsdS(uDelete all marks in markNames.N((uselfu markNames((u>/opt/alt/python33/lib64/python3.3/idlelib/idle_test/mock_tk.pyu mark_unsetþsuText.mark_unsetcCsdS(uARemove tag tagName from all characters between index1 and index2.N((uselfutagNameuindex1uindex2((u>/opt/alt/python33/lib64/python3.3/idlelib/idle_test/mock_tk.pyu tag_removesuText.tag_removecCsdS(u2Adjust the view of the text according to scan_markN((uselfuxuy((u>/opt/alt/python33/lib64/python3.3/idlelib/idle_test/mock_tk.pyu scan_dragtosuText.scan_dragtocCsdS(u&Remember the current X, Y coordinates.N((uselfuxuy((u>/opt/alt/python33/lib64/python3.3/idlelib/idle_test/mock_tk.pyu scan_mark suText.scan_markcCsdS(u8Scroll screen to make the character at INDEX is visible.N((uselfuindex((u>/opt/alt/python33/lib64/python3.3/idlelib/idle_test/mock_tk.pyuseesuText.seecCsdS(u>Bind to this widget at event sequence a call to function func.N((usequenceufuncuadd((u>/opt/alt/python33/lib64/python3.3/idlelib/idle_test/mock_tk.pyubindsu Text.bindN(u__name__u __module__u __qualname__u__doc__uNoneu__init__uindexu_decodeu_endexuinsertugetudeleteucompareumark_setu mark_unsetu tag_removeu scan_dragtou scan_markuseeubind(u __locals__((u>/opt/alt/python33/lib64/python3.3/idlelib/idle_test/mock_tk.pyuTextGs   3        uTextN(u__doc__uVaru Mbox_funcuMboxu_tkinteruTclErroruText(((u>/opt/alt/python33/lib64/python3.3/idlelib/idle_test/mock_tk.pyus  #