K ii.ddlZddlmZddlZddlZddlmZddlZddlmZm Z ddl m Z ddl Z e jrddl mZGddZGd d ej Zy) N)StringIO)mock) OptionParserError)basestring_type)Listc"eZdZdZedZy)EmailcNt|tr d|vr||_yt)N@) isinstancestr_value ValueError)selfvalues _/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/tornado/test/options_test.py__init__zEmail.__init__s! eS !cUlDK, c|jSN)rrs rrz Email.values {{rN)__name__ __module__ __qualname__rpropertyrrrr r s rr ceZdZdZdZdZdZdZdZdZ dZ d Z d Z d Z d Zd ZdZdZdZdZdZdZdZdZdZdZdZdZdZdZy) OptionsTestct}|jdd|jddg|j|jdy)NportPdefaultmain.pyz --port=443)rdefineparse_command_line assertEqualr!roptionss rtest_parse_command_linez#OptionsTest.test_parse_command_lines@.vr*""I|#<= s+rc t}|jdd|jdd|jdtjj tjj tjj td}|j||j|jd|j|jd |j|j|y) Nr!r"r#usernamefoomy_pathoptions_test.cfgr&u李康) rr'ospathjoindirnameabspath__file__parse_config_filer)r!r.r0)rr+ config_paths rtest_parse_config_filez"OptionsTest.test_parse_config_file$s.vr*z51y!ggll GGOOBGGOOH5 68J  !!+. s+ ))84 +6rctt}d_fd}|j||jdgdj j|jdgj jd_|jdgj jy)NFcd_y)NT)calledrsrcallbackz2OptionsTest.test_parse_callbacks..callback5s DKrr%)final)rr=add_parse_callbackr( assertFalse assertTrue)rr+r>s` rtest_parse_callbacksz OptionsTest.test_parse_callbacks1s.   ""8, ""I;e"< % ""I;/  $ ""I;/  $rcpt} tj}tt_|j t 5|j ddgdddtjj}|t_|jd|y#1swYExYw#t_wxYw)Nr%z--helpzUsage:) rsysstderrr assertRaises SystemExitr(getvalueassertIn)rr+ orig_stderrusages r test_helpzOptionsTest.test_helpHs. %**K!CJ"":. B**Ix+@A BJJ'')E$CJ h&  B B%CJs#8B(B&B(B%!B(( B5czt}|jddt}|jdt|jgd}|j |ddg|j |j |j|}|j |g|j |jd  tj}tt_ |jt5|jdd gddd|t_ y#1swYxYw#t_ wxYw) NverboseFr#r/type)r% --verbose subcommand --foo=barrSrTbarrR) rr'rr(r)rBrOr/rErFrrGr)r base_options sub_optionsrestrest2rKs rtest_subcommandzOptionsTest.test_subcommandTs #~ Iu5"n 5s+.. ?   k:;  ,,-..t4 # %0 %**K!CJ""5) L.. k/JK L%CJ L L%CJs$8D-9D! D-!D*&D-- D:ct}|jddtd|_|j |jdyNr/r$rQ)rr'intr/r)r*s r test_setattrzOptionsTest.test_setattrks6.uac2  a(rct}|jddt|jt5d|_dddy#1swYyxYw)Nr/r]r^2)rr'r`rGrr/r*s rtest_setattr_type_checkz#OptionsTest.test_setattr_type_checkqsG.uac2   u % GK   s A  Acg}t}|jddt|jd|_|j |dgy)Nr/r])r$rQr>r_)rr'r`appendr/r))rvaluesr+s rtest_setattr_with_callbackz&OptionsTest.test_setattr_with_callbackys?.uacFMMJ  !%rcft}|jdd|jdd|S)Nar]r#br_)rr'r*s r_sample_optionszOptionsTest._sample_optionss..sA&sA&rcp|j}|jhdtt|y)N>rjrkhelp)rlr)setiterr*s r test_iterzOptionsTest.test_iters*&&( +Sg-?@rcN|j}|jd|dy)Nr]rj)rlr)r*s r test_getitemzOptionsTest.test_getitems$&&( GCL)rc|t}|jddtd|d<|j|ddyr\)rr'r`r)r*s r test_setitemzOptionsTest.test_setitems8.uac2 +rc|j}ddd|jfg}t|j}|j ||y)N)rjr])rkr_rn)rlrnsorteditemsr))rr+expectedactuals r test_itemszOptionsTest.test_itemssE&&(h(>? ( 6*rc|j}dd|jd}|j||jy)Nr]r_)rjrkrn)rlrnr)as_dict)rr+rys r test_as_dictzOptionsTest.test_as_dicts7&&(GLL9 7??#45rct}|jdd|jdddtjd}|jj }|j dd |h|j|jd}|j ddi||j i|jd y) Nrjr]r#rkb_groupr_)groupr$r nonexistent) rr'rE _getframef_code co_filenamer)groups group_dict)rr+frame this_file b_group_dicts rtest_group_dictzOptionsTest.test_group_dicts.sA&s)Q7 a LL,,  )R3W^^5EF)))4  #q<0 W// >?rct}|jdd|jddg|j|jdt j j|jdd5|j|jdddd|j|jdt j j|jdd5|j|jdd |_|j|jd t j j|jdd 5|j|jd ddd|j|jd ddd|j|jdy#1swY*xYw#1swYWxYw#1swY?xYw) Nr/r]r#r%z--foo=2r_) rr'r(r)r/rpatchobjectmockabler*s rtest_mock_patchzOptionsTest.test_mock_patchss.ua(""Iy#9: a( ZZ  w//15! < -   W[[! , - a(ZZ  w//15! < -   W[[! ,GK   W[[! ,""7#3#3#5ua@ 1  a0 1   W[[! ,  - a( - - 1 1  - -s1<G,A/GG8$GG G GG#ct}|jdt|jdt|jdt|jdt |jdt j |jdt j|jdt|jd td |jd td |S) NrrP basestringr`floatdatetime timedeltaemailz list-of-intTrQmultiplez list-of-str) rr'rrr`rrrr r*s r_define_optionszOptionsTest._define_optionss.u3'|/:u3'wU+z(9(9:{););<wU+}3>}3>rc |j|jd|j|jd|j|jd|j|jd|j|j t j ddddd |j|j t j d |j|jjd |jt|jt|j|jgd |j|jgdy)Nasdfqwer*g?irr-)secondsztornado@web.com)r]r_rrjrkc)r)rrr`rrrrrrBr r list_of_int list_of_strr*s r_check_options_valuesz!OptionsTest._check_options_valuess f- ++V4 b) , ))8+<+,>r,JK ,,.?@  7==%89 ,,i8 ,,o>rcl|j}|jgd|j|y)N) r%z --str=asdfz--basestring=qwerz--int=42z --float=1.5z--datetime=2013-04-28 05:16z--timedelta=45sz--email=tornado@web.comz--list-of-int=1,2,3z--list-of-str=a,b,c)rr(rr*s r test_typeszOptionsTest.test_typess3&&(""   ""7+rcdD]s}|j}|jtjj tjj t ||j|uy)N)zoptions_test_types.cfgzoptions_test_types_str.cfg)rr8r2r3r4r5r7r)rconfig_file_namer+s rtest_types_with_conf_filez%OptionsTest.test_types_with_conf_filesb!  0 **,G  % % RWW__X68HI   & &w / 0rct}|jdtd|jddg|j |j gdy)Nr/Trr%z --foo=a,b,cr)rr'rr(r)r/r*s rtest_multiple_stringz OptionsTest.test_multiple_stringsB.u36""I}#=> o6rct}|jdtd|jddg|j |j gdy)Nr/Trr%z --foo=1,3,5:7)r]rrr)rr'r`r(r)r/r*s rtest_multiple_intzOptionsTest.test_multiple_intsB.u36""I#?@ o6rct}|jd|jt5}|jdddd|j t j dy#1swY/xYw)Nr/zOption.*foo.*already defined)rr'rGr assertRegexr exception)rr+cms rtest_error_redefinezOptionsTest.test_error_redefines`.u   u % " NN5 ! " R\\*,JK " "s A11A:chgd}|D]\}}|j|||5t}|j||jt5}|j|ddd|j t jddddy#1swY9xYw#1swYxYw)N))foo-barr)foo_barrrr)rr)rjrkz Option.*foo.bar.*already defined)subTestrr'rGrrrr)rtestsrjrkr+rs rtest_error_redefine_underscorez*OptionsTest.test_error_redefine_underscore s   XDAqda1- X&.q!&&u-&NN1%&  R\\!24VW  X X X&& X Xs#1B(B$-B(B% !B((B1 cdD]}}dD]v}t}|j||jd|g|j|jd|j|dd|j|ddxy)Nr)z --foo-bar=az --foo_bar=ar%rjrr)rr'r(r)r)r defined_nameflagr+s rtest_dash_underscore_cliz$OptionsTest.test_dash_underscore_clis2 :L6 :&.|,**It+<=  #6  !3S9  !3S9 : :rc dD]}t}|j||jtjj tjj td|j|jdy)Nrr1rj) rr'r8r2r3r4r5r7r)r)rrr+s rtest_dash_underscore_filez%OptionsTest.test_dash_underscore_file+sj3 3L"nG NN< (  % % RWW__X68JK    W__c 2  3rc~t}|jdd|jddgd}|jt|||jtd|j D||jt|j j ||jt|jdddgt}|j||jd|j|jd|jy) N with-dashg)rwith_underscore)rnrrc3&K|] \}}| ywrr).0kvs r zAOptionsTest.test_dash_underscore_introspection..=s@fq!@sz --with-dashz--with-underscore) rr'r)rwrxr}keysrr print_helprJrI)rr+ all_optionsbufs r"test_dash_underscore_introspectionz.OptionsTest.test_dash_underscore_introspection6s.{#.(4>  +6 @ @@+N  1 6 6 89;G  7%%c* +k;L-M j3 mS\\^4 )3<<>:rN)rrrr,r:rCrMrZrardrhrlrqrsrur{r~rrrrrrrrrrrrrrrrrrs, 7%. '%.) & A *, +6 @)*  ?,$ 07 7 LX" : 3;rr)riorr2rEunittestrtornado.optionsrr tornado.utilrtyping TYPE_CHECKINGrr TestCaserrrrrsJ /(    k;(##k;r