ok

Mini Shell

Direktori : /proc/thread-self/root/proc/self/root/usr/lib64/python2.7/idlelib/idle_test/
Upload File :
Current File : //proc/thread-self/root/proc/self/root/usr/lib64/python2.7/idlelib/idle_test/mock_tk.pyc

�
{fc@s�dZdefd��YZdefd��YZdefd��YZdefd��YZd	d
lmZdefd��YZd
S(s�Classes that replace tkinter gui objects used by an object being tested.

A gui object is anything with a master or parent parameter, which is
typically required in spite of what the doc strings say.
tEventcBseZdZd�ZRS(s�Minimal mock with attributes for testing event handlers.

    This is not a gui object, but is used as an argument for callbacks
    that access attributes of the event passed. If a callback ignores
    the event, other than the fact that is happened, pass 'event'.

    Keyboard, mouse, window, and other sources generate Event instances.
    Event instances have the following attributes: serial (number of
    event), time (of event), type (of event as number), widget (in which
    event occurred), and x,y (position of mouse). There are other
    attributes for specific events, such as keycode for key events.
    tkinter.Event.__doc__ has more but is still not complete.
    cKs|jj|�dS(s,Create event with attributes needed for testN(t__dict__tupdate(tselftkwds((s1/usr/lib64/python2.7/idlelib/idle_test/mock_tk.pyt__init__s(t__name__t
__module__t__doc__R(((s1/usr/lib64/python2.7/idlelib/idle_test/mock_tk.pyRs
tVarcBs2eZdZdddd�Zd�Zd�ZRS(s)Use for String/Int/BooleanVar: incompletecCs||_||_||_dS(N(tmastertvaluetname(RR
RR((s1/usr/lib64/python2.7/idlelib/idle_test/mock_tk.pyRs		cCs
||_dS(N(R(RR((s1/usr/lib64/python2.7/idlelib/idle_test/mock_tk.pytsetscCs|jS(N(R(R((s1/usr/lib64/python2.7/idlelib/idle_test/mock_tk.pytget!sN(RRRtNoneRR
R(((s1/usr/lib64/python2.7/idlelib/idle_test/mock_tk.pyR	s	t	Mbox_funccBs#eZdZdd�Zd�ZRS(sGeneric 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.
    The test can set the result returned to ask function
    cCs
||_dS(N(tresult(RR((s1/usr/lib64/python2.7/idlelib/idle_test/mock_tk.pyR+scOs+||_||_||_||_|jS(N(ttitletmessagetargsRR(RRRRR((s1/usr/lib64/python2.7/idlelib/idle_test/mock_tk.pyt__call__-s
				N(RRRRRR(((s1/usr/lib64/python2.7/idlelib/idle_test/mock_tk.pyR$stMboxcBsVeZdZe�Ze�Ze�Ze�Ze�Ze�Z	e�Z
e�ZRS(s5Mock 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,
    (RRRRtaskokcanceltaskquestiontaskretrycanceltaskyesnotaskyesnocancelt	showerrortshowinfotshowwarning(((s1/usr/lib64/python2.7/idlelib/idle_test/mock_tk.pyR5s							i����(tTclErrortTextcBs�eZdZdid�Zd�Zdd�Zd�Zd�Zdd�Z	dd�Z
d	�Zd
�Zd�Z
dd�Zd
�Zd�Zd�Zdddd�ZRS(s�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(s�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.
        ts
N(tdata(RR
tcnftkw((s1/usr/lib64/python2.7/idlelib/idle_test/mock_tk.pyRgscCsd|j|dd�S(sAReturn string version of index decoded according to current text.s%s.%stendflagi(t_decode(Rtindex((s1/usr/lib64/python2.7/idlelib/idle_test/mock_tk.pyR'osicCsqt|ttf�r$t|�}ny|j�}Wn!tk
rWtd|��nXt|j�d}|dkr�|t|j|�dfS|dkr�|j	|�S|j
d�\}}t|�}|dkr�dS||kr�|j	|�St|j|�d}|jd�s'|dkr1||fSt|�}|dkrRd}n||krg|}n||fS(	s7Return 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.
        sbad text index "%s"itinserttendt.is lineend(ii(
t
isinstancetfloattbyteststrtlowertAttributeErrorRtlenR"t_endextsplittinttendswith(RR'R%tlastlinetlinetchart
linelength((s1/usr/lib64/python2.7/idlelib/idle_test/mock_tk.pyR&ss4



		cCsNt|j�}|dkr%|dfS|d8}|t|j|�|fSdS(sReturn 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(R1R"(RR%tn((s1/usr/lib64/python2.7/idlelib/idle_test/mock_tk.pyR2�s


cCs�|s
dS|jt�}|dddkr=|jd�n|j|d�\}}|j|| }|j||}||d|j|<|d|j|d|d+|j|t|�dc|7<dS(s+Insert chars before the character at index.Ni����s
R!ii(t
splitlinestTruetappendR&R"R1(RR'tcharsR7R8tbeforetafter((s1/usr/lib64/python2.7/idlelib/idle_test/mock_tk.pyR(�sc	Cs�|j|�\}}|dkr5||d}}n|j|�\}}||krh|j|||!S|j||g}x/t|d|�D]}|j|j|�q�W|j|j|| �dj|�SdS(s;Return slice from index1 to index2 (default is 'index1+1').iR!N(R&RR"trangeR=tjoin(	Rtindex1tindex2t	startlinet	startchartendlinetendchartlinesti((s1/usr/lib64/python2.7/idlelib/idle_test/mock_tk.pyR�scCsO|j|d�\}}|dkr�|t|j|�dkrU||d}}q�|t|j�dkr�|dd}}q�dSn|j|d�\}}||kr�||kr�|j|| |j|||j|<nh||krK|j|| |j|||j|<|d7}x(t||d�D]}|j|=q4WndS(s�Delete slice from index1 to index2 (default is 'index1+1').

        Adjust default index2 ('index+1) for line ends.
        Do not delete the terminal 
 at the very end of self.data ([-1][-1]).
        i����iiN(R&RR1R"RA(RRCRDRERFRGRHRJ((s1/usr/lib64/python2.7/idlelib/idle_test/mock_tk.pytdelete�s"
cCs:|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(Nt<s<=t>s>=s==s!=s=bad comparison operator "%s": must be <, <=, ==, >=, >, or !=(R&R(RRCtopRDtline1tchar1tline2tchar2((s1/usr/lib64/python2.7/idlelib/idle_test/mock_tk.pytcompare�s """"cCsdS(s.Set mark *name* before the character at index.N((RRR'((s1/usr/lib64/python2.7/idlelib/idle_test/mock_tk.pytmark_set
scGsdS(sDelete all marks in markNames.N((Rt	markNames((s1/usr/lib64/python2.7/idlelib/idle_test/mock_tk.pyt
mark_unsetR!cCsdS(sARemove tag tagName from all characters between index1 and index2.N((RttagNameRCRD((s1/usr/lib64/python2.7/idlelib/idle_test/mock_tk.pyt
tag_removescCsdS(s2Adjust the view of the text according to scan_markN((Rtxty((s1/usr/lib64/python2.7/idlelib/idle_test/mock_tk.pytscan_dragtoR!cCsdS(s&Remember the current X, Y coordinates.N((RRYRZ((s1/usr/lib64/python2.7/idlelib/idle_test/mock_tk.pyt	scan_markR!cCsdS(s8Scroll screen to make the character at INDEX is visible.N((RR'((s1/usr/lib64/python2.7/idlelib/idle_test/mock_tk.pytsee!scCsdS(s>Bind to this widget at event sequence a call to function func.N((tsequencetfunctadd((s1/usr/lib64/python2.7/idlelib/idle_test/mock_tk.pytbind(sN(RRRRRR'R&R2R(RRKRSRTRVRXR[R\R]Ra(((s1/usr/lib64/python2.7/idlelib/idle_test/mock_tk.pyR Zs 	3								N(	RtobjectRR	RRt_tkinterRR (((s1/usr/lib64/python2.7/idlelib/idle_test/mock_tk.pyt<module>s#

Zerion Mini Shell 1.0