Your IP : 18.118.19.89
�
{fc @ s� d Z d e f d � � YZ d e f d � � YZ d e f d � � YZ d e f d � � YZ d d
l m Z d e f d � � YZ d
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.
t Eventc B s e Z d Z d � Z RS( 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.
c K s | j j | � d S( s, Create event with attributes needed for testN( t __dict__t update( t selft kwds( ( 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.pyR s
t Varc B s2 e Z d Z d d d d � Z d � Z d � Z RS( s) Use for String/Int/BooleanVar: incompletec C s | | _ | | _ | | _ d S( N( t mastert valuet name( R R
R R ( ( s1 /usr/lib64/python2.7/idlelib/idle_test/mock_tk.pyR s c C s
| | _ d S( N( R ( R R ( ( s1 /usr/lib64/python2.7/idlelib/idle_test/mock_tk.pyt set s c C s | j S( N( R ( R ( ( s1 /usr/lib64/python2.7/idlelib/idle_test/mock_tk.pyt get! s N( R R R t NoneR R
R ( ( ( s1 /usr/lib64/python2.7/idlelib/idle_test/mock_tk.pyR s t Mbox_funcc B s# e Z d Z d d � Z d � Z RS( s 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.
The test can set the result returned to ask function
c C s
| | _ d S( N( t result( R R ( ( s1 /usr/lib64/python2.7/idlelib/idle_test/mock_tk.pyR + s c O s+ | | _ | | _ | | _ | | _ | j S( N( t titlet messaget argsR R ( R R R R R ( ( s1 /usr/lib64/python2.7/idlelib/idle_test/mock_tk.pyt __call__- s
N( R R R R R R ( ( ( s1 /usr/lib64/python2.7/idlelib/idle_test/mock_tk.pyR $ s t Mboxc B sV e Z d Z e � Z e � Z e � Z e � Z e � Z e � Z e � Z
e � Z RS( s5 Mock 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,
( R R R R t askokcancelt askquestiont askretrycancelt askyesnot askyesnocancelt showerrort showinfot showwarning( ( ( s1 /usr/lib64/python2.7/idlelib/idle_test/mock_tk.pyR 5 s i����( t TclErrort Textc B s� e Z d Z d i d � Z d � Z d d � Z d � Z d � Z d d � Z d d � Z
d � Z d
� Z d � Z
d d � Z d
� Z d � Z d � Z d d d d � Z RS( 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.
c K s d d g | _ d S( 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.
t s
N( t data( R R
t cnft kw( ( s1 /usr/lib64/python2.7/idlelib/idle_test/mock_tk.pyR g s c C s d | j | d d �S( sA Return string version of index decoded according to current text.s %s.%st endflagi ( t _decode( R t index( ( s1 /usr/lib64/python2.7/idlelib/idle_test/mock_tk.pyR'