• File: test_config_key.cpython-37.pyc
  • Full Path: /home3/farmfre2/public_html/ALFA_DATA/alfasymlink/root/opt/alt/python37/lib64/python3.7/idlelib/idle_test/__pycache__/test_config_key.cpython-37.pyc
  • Date Modified: 10/26/2026 8:08 PM
  • File size: 10.55 KB
  • MIME-type: text/x-bytecode.python
  • Charset: 8 bit
B

Nj%@sdZddlmZddlmZddlZddlmZddlmZm	Z	ddl
mZddlm
Z
ejZGd	d
d
ejZGdddejZGd
ddejZGdddejZGdddejZedkrejdddS)zTest config_key, coverage 98%.

Coverage is effectively 100%.  Tkinter dialog is mocked, Mac-only line
may be skipped, and dummy function in bind test should not be called.
Not tested: exit with 'self.advanced or self.keys_ok(keys)) ...' False.
)
config_key)requiresN)mock)TkTclError)Func)	Mbox_funcc@seZdZdZGdddeZeddZeddZdd	Z	d
dZ
dd
ZddZddZ
ddZddZddZddZddZdS)ValidationTestz.Test validation methods: ok, keys_ok, bind_ok.c@s eZdZddZeZeZdS)zValidationTest.ValidatorcOs,tjj|f||Gddd}||_dS)Nc@seZdZeZdS)z:ValidationTest.Validator.__init__.<locals>.list_keys_finalN)__name__
__module____qualname__rgetrrF/opt/alt/python37/lib64/python3.7/idlelib/idle_test/test_config_key.pylist_keys_finalsr)r
GetKeysDialog__init__r)selfargskwargsrrrrrsz!ValidationTest.Validator.__init__N)r
rrrr
get_modifiersr	showerrorrrrr	ValidatorsrcCsDtdt|_|jdgddgg}|j|jdd|dd|_dS)	Nguiz	<Key-F12>z<Control-Key-x>z<Control-Key-X>Titlez<<Test>>T)_utest)rrrootwithdrawrdialog)clsZkeylistrrr
setUpClasss
zValidationTest.setUpClasscCs*|j|j|j|`|`dS)N)rcancelrupdate_idletasksdestroy)rrrr
tearDownClass(s


zValidationTest.tearDownClasscCsd|jj_dS)N)rrmessage)rrrrsetUp/szValidationTest.setUpcCs>|jjd|j||jjd||jjjddS)N r%zNo key specified.)r
key_stringsetokassertEqualresultrr&)rrrr
test_ok_empty4s
zValidationTest.test_ok_emptycCsJ|jjdd|jjj_|j||jjd||jjj	ddS)Nz	<Key-F11>F11r%)
rr)r*rr
r-r+r,rr&)rrrrtest_ok_good:s

zValidationTest.test_ok_goodcCs(||jd|d|jjjdS)Nz<Control-ShiftzMissing the final)assertFalserkeys_okassertInrr&)rrrrtest_keys_no_endingAsz"ValidationTest.test_keys_no_endingcCs4d|jjj_||jd|d|jjjdS)NAz<Key-A>zNo modifier)	rrr
r-r1r2r3rr&)rrrrtest_keys_no_modifier_badEsz(ValidationTest.test_keys_no_modifier_badcCs4d|jjj_||jd||jjjddS)Nr/z	<Key-F11>r%)	rrr
r-
assertTruer2r,rr&)rrrrtest_keys_no_modifier_okJsz'ValidationTest.test_keys_no_modifier_okcCsJd|jjj_dg|jj_||jd|d|jjj	g|jj_dS)NaShiftz<a>zshift modifier)
rrr
r-rr1r2r3rr&)rrrrtest_keys_shift_badOs
z"ValidationTest.test_keys_shift_badc
CsxgddfdgddfdgddffD]`\}}}|j|||d@||jjj_||jj_||j||d	|jj	j
WdQRXq"Wg|jj_dS)
NZF12z	<Key-F12>Controlxz<Control-Key-x>Xz<Control-Key-X>)mfszalready in use)ZsubTestrrr
r-rr1r2r3rr&)rZmodsfinalseqrrr
test_keys_dupVs


 zValidationTest.test_keys_dupcCs(||jd||jjjddS)Nz<Control-Shift-Key-a>r%)r7rbind_okr,rr&)rrrrtest_bind_okaszValidationTest.test_bind_okcCs(||jd|d|jjjdS)Nz<Control-Shift>znot accepted)r1rrEr3rr&)rrrrtest_bind_not_okeszValidationTest.test_bind_not_okN)r
rr__doc__gkdrclassmethodr r$r'r.r0r4r6r8r;rDrFrGrrrrr	s		r	c@s0eZdZdZeddZeddZddZdS)	ToggleLevelTestz.Test toggle between Basic and Advanced frames.cCs4tdt|_|jt|jddgdd|_dS)Nrrz<<Test>>T)r)rrrrrIr)rrrrr ms
zToggleLevelTest.setUpClasscCs*|j|j|j|`|`dS)N)rr!rr"r#)rrrrr$ts


zToggleLevelTest.tearDownClasscs|jfdd}|j|djd|\}}||||j|djd|\}}|||j|j|djd|\}}|||dS)Ncs@x6tjD]$\}}|jdkr&|}|jdkr|}qW||fS)zGet the stack order of the children of the frame.

            winfo_children() stores the children in stack order, so
            this can be used to check whether a frame is above or
            below another one.
            Zkeyseq_basicZkeyseq_advanced)	enumerateframeZwinfo_children_name)indexZchildbasicadvanced)rrr
stackorder~s

z5ToggleLevelTest.test_toggle_level.<locals>.stackorderZAdvancedtextBasic)	rr1rQr3Zbutton_levelZ
assertGreaterZtoggle_levelr7invoke)rrRrPrQr)rrtest_toggle_level{s 



z!ToggleLevelTest.test_toggle_levelN)r
rrrHrJr r$rVrrrrrKjsrKc@steZdZdZGdddeZeddZeddZdd	Z	d
dZ
ej
edd
dZej
edddZdS)KeySelectionTestz#Test selecting key on Basic frames.cs*eZdZfddZddZeZZS)zKeySelectionTest.Basiccs&tj||Gddd}||_dS)Nc@seZdZeZeZeZdS)z8KeySelectionTest.Basic.__init__.<locals>.list_keys_finalN)r
rrrr
Zselect_clearZyviewrrrrrsr)superrr)rrrr)	__class__rrrszKeySelectionTest.Basic.__init__cCsdddg|_ddi|_dS)NfooZbarBAZZZZZ)Z	modifiersZmodifier_label)rrrrset_modifiers_for_platformsz1KeySelectionTest.Basic.set_modifiers_for_platform)r
rrrr\rr
__classcell__rr)rYrrTsrTcCs6tdt|_|j|j|jddgdd|_dS)Nrrz<<Test>>T)r)rrrrrTr)rrrrr s
zKeySelectionTest.setUpClasscCs*|j|j|j|`|`dS)N)rr!rr"r#)rrrrr$s


zKeySelectionTest.tearDownClasscCs|jdS)N)rZ
clear_key_seq)rrrrr'szKeySelectionTest.setUpcCsl|j}|j}|j}|jd||dg|jd||ddg|jd||dgdS)NrZr[)rrr,Zmodifier_checkbuttonsrU)rrZgmeqrrrtest_get_modifierssz#KeySelectionTest.test_get_modifiersrcCs|j}|j}|jj}|j}d|j_g|_|||ddg|_|||dd|j_ddg|_|||ddS)Nr9z<Key-a>Zmymodz
<mymod-Key-a>r%Ztestz<mymod-test>)rrr)r
r,r-return_valueZbuild_key_string)rmock_modifiersrkeystringr^rrrtest_build_key_strings
z&KeySelectionTest.test_build_key_stringcCsB|j}|j}|jj}|j}dg|_d|j_|||ddS)Nr:{z<Shift-Key-braceleft>)rrr)r
r,r`r-Zfinal_key_selected)rrarrbrcr^rrrtest_final_key_selectedsz(KeySelectionTest.test_final_key_selectedN)r
rrrHrIrTrJr r$r'r_rZpatchobjectrdrfrrrrrWs
rWc@s0eZdZdZeddZeddZddZdS)	
CancelTestz'Simulate user clicking [Cancel] button.cCs4tdt|_|jt|jddgdd|_dS)Nrrz<<Test>>T)r)rrrrrIr)rrrrr s
zCancelTest.setUpClasscCs*|j|j|j|`|`dS)N)rr!rr"r#)rrrrr$s


zCancelTest.tearDownClassc	CsR||jd|jj|t|jWdQRX||jjddS)NZToplevelr%)r,rZwinfo_classZ
button_cancelrUZassertRaisesrr-)rrrrtest_cancels
zCancelTest.test_cancelN)r
rrrHrJr r$rirrrrrhsrhc@seZdZdZddZdS)
HelperTestz#Test module level helper functions.cCstj}|j}||dgd||dddgd||ddgd||dddgd||ddddgd||dgd||d	dgd
dS)NqzKey-qr<ZAltr:zKey-QzPage Upz	Key-Prior*zKey-asterisk)rZ
translate_keyr,)rZtrr^rrrtest_translate_keyszHelperTest.test_translate_keyN)r
rrrHrmrrrrrjsrj__main__)	verbosity)rHZidlelibrZtest.supportrZunittestrZtkinterrrZidlelib.idle_test.mock_idlerZidlelib.idle_test.mock_tkrrrIZTestCaser	rKrWrhrjr
mainrrrr<module>sW7R