{G_Tc@sZddlZddlZddlZddlZddlZddlZddlmZddlmZddl m Z m Z m Z m Z mZmZmZmZmZmZmZddl mZddl mZeejdZdefd YZd e fd YZd ejfd YZdefdYZdefdYZ defdYZ!defdYZ"idd6dd6d]d6d_d6Z#dZ$de fdYZ%d efd!YZ&d"efd#YZ'd$efd%YZ(d&efd'YZ)d(efd)YZ*d*efd+YZ+d,efd-YZ,d.efd/YZ-d0efd1YZ.d2efd3YZ/d4efd5YZ0d6efd7YZ1d8efd9YZ2d:efd;YZ3d<efd=YZ4d>efd?YZ5d@efdAYZ6dBefdCYZ7dDefdEYZ8dFefdGYZ9dHefdIYZ:dJe:fdKYZ;dLe:fdMYZ<dNefdOYZ=dPZ>dQZ?dRZ@dSZAdTZBdUefdVYZCdWefdXYZDdYefdZYZEd[ZFeGd\krVeFndS(`iN(tStringIO(t test_support( t make_optiontOptiontTitledHelpFormattert OptionParsert OptionGrouptSUPPRESS_USAGEt OptionErrortOptionConflictErrortBadOptionErrortOptionValueErrortValues(t _match_abbrev(t _parse_numttInterceptedErrorcBs#eZddddZdZRS(cCs||_||_||_dS(N(t error_messaget exit_statust exit_message(tselfRRR((s./usr/local/lib/python2.7/test/test_optparse.pyt__init__s  cCs|jp|jpdS(Nsintercepted error(RR(R((s./usr/local/lib/python2.7/test/test_optparse.pyt__str__&sN(t__name__t __module__tNoneRR(((s./usr/local/lib/python2.7/test/test_optparse.pyRs tInterceptingOptionParsercBs eZdddZdZRS(icCstd|d|dS(NRR(R(Rtstatustmsg((s./usr/local/lib/python2.7/test/test_optparse.pytexit*scCstd|dS(NR(R(RR((s./usr/local/lib/python2.7/test/test_optparse.pyterror-sN(RRRRR(((s./usr/local/lib/python2.7/test/test_optparse.pyR)stBaseTestcBsDeZdZdZdZdddZdZdZRS(cCsb|jj|\}}t|}|j||dt|j||dt||fS(sAssert the options are what we expected when parsing arguments. Otherwise, fail with a nicely formatted message. Keyword arguments: args -- A list of arguments to parse with OptionParser. expected_opts -- The options expected. expected_positional_args -- The positional arguments expected. Returns the options and positional args for further testing. sJ Options are %(optdict)s. Should be %(expected_opts)s. Args were %(args)s.sj Positional arguments are %(positional_args)s. Should be %(expected_positional_args)s. Args were %(args)s.(tparsert parse_argstvarst assertEqualtlocals(Rtargst expected_optstexpected_positional_argstoptionstpositional_argstoptdict((s./usr/local/lib/python2.7/test/test_optparse.pyt assertParseOK2s    cCs|dkrd}n|dkr*i}ny|||Wnu|k r}t|}t|tr|j|j|d|j|fn|j||d||f|SX|jdt dS(s- Assert that the expected exception is raised when calling a function, and that the right error message is included with that exception. Arguments: func -- the function to call args -- positional arguments to `func` kwargs -- keyword arguments to `func` expected_exception -- exception that should be raised expected_message -- expected exception message (or pattern if a compiled regex object) Returns the exception raised for further testing. sLexpected exception message pattern: /%s/ actual exception message: '''%s''' sHexpected exception message: '''%s''' actual exception message: '''%s''' snexpected exception %(expected_exception)s not raised called %(func)r with args %(args)r and kwargs %(kwargs)r N(( Rtstrt isinstancetretypet assertTruetsearchtpatternR#tfailR$(RtfuncR%tkwargstexpected_exceptiontexpected_messageterrtactual_message((s./usr/local/lib/python2.7/test/test_optparse.pyt assertRaisesPs"      cCsNy|jj|Wn&tk r<}|j|j|nX|jddS(s Assert the parser fails with the expected message. Caller must ensure that self.parser is an InterceptingOptionParser. sexpected parse failureN(R R!RR#Rt assertFalse(Rt cmdline_argstexpected_outputR7((s./usr/local/lib/python2.7/test/test_optparse.pytassertParseFails ic Cstj}t|dd}yUz5tt_|rB|tj_n|jj|Wdtjj}|t_XWnt k r}|j t |t j kdt |||kr|jd|d|dn|j|j||j|j|nX|jddS(s7Assert the parser prints the expected output on stdout.tencodingNs0expected output to be an ordinary string, not %rsexpected: ''' s''' but got ''' s'''sexpected parser.exit()(tsyststdouttgetattrRRR>R R!tgetvalueRR/ttypettypest StringTypeR2R#RRR:( RR;R<texpected_statustexpected_errort save_stdoutR>toutputR7((s./usr/local/lib/python2.7/test/test_optparse.pyt assertOutputs*   cGs|j||dt|dS(s4Assert that TypeError is raised when executing func.N(R9Rt TypeError(RR3R6R%((s./usr/local/lib/python2.7/test/test_optparse.pytassertTypeErrorscCs>|j}||kr:|jd|d|dndS(Nshelp text failure; expected: "s "; got: "s" (t format_helptfailureException(RR t expected_helpt actual_help((s./usr/local/lib/python2.7/test/test_optparse.pyt assertHelps  N( RRR+R9R=RRJRLRQ(((s./usr/local/lib/python2.7/test/test_optparse.pyR1s  ;   tTestOptionCheckscBseZdZgidZdZdZdZdZdZdZ dZ d Z d Z d Z d Zd ZdZdZdZdZdZdZdZdZRS(cCstdt|_dS(Ntusage(RRR (R((s./usr/local/lib/python2.7/test/test_optparse.pytsetUpscCs|jt||t|dS(N(R9RR(RR6R%R4((s./usr/local/lib/python2.7/test/test_optparse.pytassertOptionErrorscCs|jtddS(Ns+at least one option string must be supplied(RLR(R((s./usr/local/lib/python2.7/test/test_optparse.pyttest_opt_string_emptys cCs|jddgdS(Ns?invalid option string 'b': must be at least two characters longtb(RU(R((s./usr/local/lib/python2.7/test/test_optparse.pyttest_opt_string_too_shortscCs|jddgdS(NsOinvalid short option string '--': must be of the form -x, (x any non-dash char)s--(RU(R((s./usr/local/lib/python2.7/test/test_optparse.pyttest_opt_string_short_invalidscCs|jddgdS(NsJinvalid long option string '---': must start with --, followed by non-dashs---(RU(R((s./usr/local/lib/python2.7/test/test_optparse.pyttest_opt_string_long_invalidscCs(|jddgidd6dd6dS(Ns.option -b: invalid keyword arguments: bar, foos-btfootbar(RUR(R((s./usr/local/lib/python2.7/test/test_optparse.pyttest_attr_invalidscCs!|jddgidd6dS(Ns option -b: invalid action: 'foo's-bR[taction(RU(R((s./usr/local/lib/python2.7/test/test_optparse.pyttest_action_invalidscCs>|jddgidd6|jddgitd6dS(Ns%option -b: invalid option type: 'foo's-bR[RCs'option -b: invalid option type: 'tuple'(RUttuple(R((s./usr/local/lib/python2.7/test/test_optparse.pyttest_type_invalids cCs(|jddgidd6dd6dS(Ns4option -b: must not supply a type for action 'count's-btcountR^tintRC(RU(R((s./usr/local/lib/python2.7/test/test_optparse.pyttest_no_type_for_actionscCs$|jdddgidd6dS(Ns@option -b/--bad: must supply a list of choices for type 'choice's-bs--badtchoiceRC(RU(R((s./usr/local/lib/python2.7/test/test_optparse.pyttest_no_choices_listscCs>tdj}|jd|ddgidd6dd6dS( NRsBoption -b/--bad: choices must be a list of strings ('%s' supplied)s-bs--badReRCs bad choicestchoices(RCRRU(Rttypename((s./usr/local/lib/python2.7/test/test_optparse.pyttest_bad_choices_lists  cCs(|jddgidd6dd6dS(Ns1option -b: must not supply choices for type 'int's-bRcRCtbadRg(RU(R((s./usr/local/lib/python2.7/test/test_optparse.pyttest_no_choices_for_type scCs(|jddgidd6dd6dS(Ns:option -b: 'const' must not be supplied for action 'store's-btstoreR^itconst(RU(R((s./usr/local/lib/python2.7/test/test_optparse.pyttest_no_const_for_actionscCs(|jddgidd6dd6dS(Ns:option -b: 'nargs' must not be supplied for action 'count's-bRbR^itnargs(RU(R((s./usr/local/lib/python2.7/test/test_optparse.pyttest_no_nargs_for_actionscCs(|jddgidd6dd6dS(Ns'option -b: callback not callable: 'foo's-btcallbackR^R[(RU(R((s./usr/local/lib/python2.7/test/test_optparse.pyttest_callback_not_callablescCsdS(N((R((s./usr/local/lib/python2.7/test/test_optparse.pytdummy scCs2|jddgidd6|jd6dd6dS(NsAoption -b: callback_args, if supplied, must be a tuple: not 'foo's-bRqR^R[t callback_args(RURs(R((s./usr/local/lib/python2.7/test/test_optparse.pyttest_callback_args_no_tuple#s  cCs2|jddgidd6|jd6dd6dS(NsBoption -b: callback_kwargs, if supplied, must be a dict: not 'foo's-bRqR^R[tcallback_kwargs(RURs(R((s./usr/local/lib/python2.7/test/test_optparse.pyttest_callback_kwargs_no_dict+s  cCs(|jddgidd6dd6dS(Ns<option -b: callback supplied ('foo') for non-callback options-bRlR^R[Rq(RU(R((s./usr/local/lib/python2.7/test/test_optparse.pyttest_no_callback_for_action3scCs(|jddgidd6dd6dS(Ns9option -b: callback_args supplied for non-callback options-bRlR^R[Rt(RU(R((s./usr/local/lib/python2.7/test/test_optparse.pyt test_no_callback_args_for_action9scCs(|jddgidd6dd6dS(Ns;option -b: callback_kwargs supplied for non-callback options-bRlR^R[Rv(RU(R((s./usr/local/lib/python2.7/test/test_optparse.pyt"test_no_callback_kwargs_for_action?s(RRRTRURVRXRYRZR]R_RaRdRfRiRkRnRpRrRsRuRwRxRyRz(((s./usr/local/lib/python2.7/test/test_optparse.pyRRs,                    tTestOptionParsercBseZdZdZdZdZdZdZdZdZ dZ d Z e j d d ed ZRS( c CsWt|_|jjdddddddd|jjd d d dd dddS( Ns-vs --verboses-ns--noisyR^t store_truetdesttverboses-qs--quiets--silentt store_false(RR t add_option(R((s./usr/local/lib/python2.7/test/test_optparse.pyRTFs   cCs|j|jjdddS(Nsnot an Option instance: None(RLR RR(R((s./usr/local/lib/python2.7/test/test_optparse.pyttest_add_option_no_OptionMscCs |j|jjddddS(Nsinvalid arguments(RLR RR(R((s./usr/local/lib/python2.7/test/test_optparse.pyt!test_add_option_invalid_argumentsQscCs~|jjd}|j|t|j|jddg|j|jddg|j|jd|j|jddS(Ns-vs-ns --verboses--noisyR|R~( R t get_optiontassertIsInstanceRR#t _short_optst _long_optsR^R}(Rtopt1((s./usr/local/lib/python2.7/test/test_optparse.pyttest_get_optionUs cCsz|jjd}|jjd}|jjd}|jjd}|j||kop|kop|kndS(Ns-vs --verboses-ns--noisy(R RR/(RRtopt2topt3topt4((s./usr/local/lib/python2.7/test/test_optparse.pyttest_get_option_equals]s cCs6|j|jjd|j|jjddS(Ns-vs --verbose(R/R t has_option(R((s./usr/local/lib/python2.7/test/test_optparse.pyttest_has_optiondscCs|j|jjddk|j|jjddk|j|jjddk|j|jjddk|j|jjd|j|jjd|j|jjd|j|jjd|j|jjd|j|jjddS(Ns-vs --verboses-ns--noisys-qs--silent(R/R RRR:R(R((s./usr/local/lib/python2.7/test/test_optparse.pytassertTrueremovedhscCs|jjd|jdS(Ns-n(R t remove_optionR(R((s./usr/local/lib/python2.7/test/test_optparse.pyttest_remove_short_optvscCs|jjd|jdS(Ns --verbose(R RR(R((s./usr/local/lib/python2.7/test/test_optparse.pyttest_remove_long_optzscCs#|j|jjddtddS(NR[sno such option 'foo'(sfoo(R9R RRt ValueError(R((s./usr/local/lib/python2.7/test/test_optparse.pyttest_remove_nonexistent~ssRelies on sys.getrefcounttcpythoncCsddg}tj|}t}|jdd||_|j~|j|tj|dS(Ni*s-as --aaarggh(R?t getrefcountRRt big_thingtdestroyR#(RRtrefcountR ((s./usr/local/lib/python2.7/test/test_optparse.pyt test_refleaks    (RRRTRRRRRRRRRRt impl_detailtTrueR(((s./usr/local/lib/python2.7/test/test_optparse.pyR{Es          tTestOptionValuescBseZdZdZRS(cCsdS(N((R((s./usr/local/lib/python2.7/test/test_optparse.pyRTscCst}|jt|i|j|i|j|idd6|j|didd6dd6}td|}|jt|||j|||j|idd6|j|i|j|d|j|gdS(NR\R[Ri*tbaztdefaults(R R#R"tassertNotEqual(Rtvaluestdict((s./usr/local/lib/python2.7/test/test_optparse.pyt test_basicss (RRRTR(((s./usr/local/lib/python2.7/test/test_optparse.pyRs tTestTypeAliasescBs,eZdZdZdZdZRS(cCst|_dS(N(RR (R((s./usr/local/lib/python2.7/test/test_optparse.pyRTscCs9|jjddd|j|jjdjddS(Ns-sRCR,tstring(R RR#RRC(R((s./usr/local/lib/python2.7/test/test_optparse.pyttest_str_aliases_stringscCsn|jjddt|j|jjdjd|jjddt|j|jjdjddS(Ns-sRCRs-xRc(R RR,R#RRCRc(R((s./usr/local/lib/python2.7/test/test_optparse.pyttest_new_type_objectscCst|jjddtj|j|jjdjd|jjddtj|j|jjdjddS(Ns-sRCRs-xRc(R RRDRER#RRCtIntType(R((s./usr/local/lib/python2.7/test/test_optparse.pyttest_old_type_objects(RRRTRRR(((s./usr/local/lib/python2.7/test/test_optparse.pyRs   itsi<tmthitdcCsly8|djrt|St|d t|dSWn-ttfk rgtd||fnXdS(Nisoption %s: invalid duration: %r(tisdigitRct _time_unitsRt IndexErrorR (toptiontopttvalue((s./usr/local/lib/python2.7/test/test_optparse.pyt_check_durations tDurationOptioncBs1eZejdZejejZeed|jddddgidd6dd6ddgd6gdS( Ns-aRs --foo=blahs--foo=RRRR[(R+R(R((s./usr/local/lib/python2.7/test/test_optparse.pyt"test_shortopt_empty_longopt_appendscCsD|jdddddgidd6dd6dddgd6gdS( Ns--fooR\Rs--foo=xRRRR[(R+R(R((s./usr/local/lib/python2.7/test/test_optparse.pyttest_long_option_appends  cCs/|jdgidd6dd6dd6gdS(Ns-abctbcRRR[(R+R(R((s./usr/local/lib/python2.7/test/test_optparse.pyttest_option_argument_joineds cCs2|jddgidd6dd6dd6gdS(Ns-at34RRR[(R+R(R((s./usr/local/lib/python2.7/test/test_optparse.pyttest_option_argument_splitscCs/|jdgidd6dd6dd6gdS(Ns-b34Ri"RR[(R+R(R((s./usr/local/lib/python2.7/test/test_optparse.pyt#test_option_argument_joined_integers cCs2|jddgidd6dd6dd6gdS(Ns-bs-5RiRR[(R+R(R((s./usr/local/lib/python2.7/test/test_optparse.pyt+test_option_argument_split_negative_integerscCs/|jdgidd6dd6dd6gdS(Ns--boo=13Ri RR[(R+R(R((s./usr/local/lib/python2.7/test/test_optparse.pyt test_long_option_argument_joineds cCs2|jddgidd6dd6dd6gdS(Ns--boot111RioRR[(R+R(R((s./usr/local/lib/python2.7/test/test_optparse.pyttest_long_option_argument_splitscCs5|jddgidd6dd6dgd6gdS(Ns --foo=bars-axyztxyzRRR\R[(R+R(R((s./usr/local/lib/python2.7/test/test_optparse.pyttest_long_option_short_optionscCs5|jddgidd6dd6dgd6gdS(Ns--f=bars-axyzRRRR\R[(R+R(R((s./usr/local/lib/python2.7/test/test_optparse.pyttest_abbrev_long_optionscCsG|jjg\}}|jj}|jt|t|dS(N(R R!RR#R"(RR(R%R((s./usr/local/lib/python2.7/test/test_optparse.pyt test_defaultsscCs9|jjddddddd|jdgd dS( Ns--fozR^RlRCRR}R[s--f=bars%ambiguous option: --f (--foo, --foz?)(R RR=(R((s./usr/local/lib/python2.7/test/test_optparse.pyttest_ambiguous_options  cCs>|jddddgidd6dd6dgd6gfdS(Ns-aRs--fooR\RRR[(R+R(R((s./usr/local/lib/python2.7/test/test_optparse.pyt test_short_and_long_option_splitscCsA|jdddddgidd6dd6d dgd 6gdS( Ns --foo=bars-bt123s--fooRRi{RR\R[(R+R(R((s./usr/local/lib/python2.7/test/test_optparse.pyt*test_short_option_split_long_option_appendscCs;|jdddgidd6dd6dd6dgfdS(Ns-aR[R\RR(R+R(R((s./usr/local/lib/python2.7/test/test_optparse.pyt*test_short_option_split_one_positional_argscCs{|jddddgidd6dd6dd6ddgf|jddddgidd6dd6dgd6gfdS(Ns-as--R[R\RRs--foo(R+R(R((s./usr/local/lib/python2.7/test/test_optparse.pyt$test_short_option_consumes_separators cCsA|jddddgidd6dd6dd6ddgfdS( Ns-abs--s--fooR\RWRRR[(R+R(R((s./usr/local/lib/python2.7/test/test_optparse.pyt&test_short_option_joined_and_separatorscCs>|jddddgidd6dd6dgd6dgdS( Ns-abt-s--fooR\RWRRR[(R+R(R((s./usr/local/lib/python2.7/test/test_optparse.pyt"test_hyphen_becomes_positional_argscCsD|jddddddgidd6dd 6d dgd 6gdS( Ns-b3s-bt5s --foo=bars--fooRRiRR\R[(R+R(R((s./usr/local/lib/python2.7/test/test_optparse.pyttest_no_append_versus_appendscCs2|jddgidd6dd6dd6gdS(Ns-as-b3RRR[(R+R(R((s./usr/local/lib/python2.7/test/test_optparse.pyt&test_option_consumes_optionlike_stringscCs-|jjddd|jdgddS(Ns-tR^R|s-testsno such option: -e(R RR=(R((s./usr/local/lib/python2.7/test/test_optparse.pyt#test_combined_single_invalid_options cCsO|jjdddd|jdgidd6dd6dd6td 6gdS( Nu-uu --unicodeR^R|s-uRRR[tunicode(R RR+RR(R((s./usr/local/lib/python2.7/test/test_optparse.pyttest_add_option_accepts_unicodes (RRRTRRRRRRRRR R R R RRRRRRRRRRRRRRR!(((s./usr/local/lib/python2.7/test/test_optparse.pyR{s8                           tTestBoolcBs5eZdZdZdZdZdZRS(c CsRtddddddddtd d dd ddg}td ||_dS( Ns-vs --verboseR^R|R}R~RRs-qs--quietRR(RRR (RR(((s./usr/local/lib/python2.7/test/test_optparse.pyRT s cCs|jgidd6gdS(NRR~(R+(R((s./usr/local/lib/python2.7/test/test_optparse.pyttest_bool_defaults  cCs?|jdgidd6g\}}|j|jtkdS(Ns-qiR~(R+R/R~R(RR(R%((s./usr/local/lib/python2.7/test/test_optparse.pyttest_bool_falses  cCs?|jdgidd6g\}}|j|jtkdS(Ns-viR~(R+R/R~R(RR(R%((s./usr/local/lib/python2.7/test/test_optparse.pyttest_bool_true$s  cCs'|jdddgidd6gdS(Ns-qvqs-qs-viR~(R+(R((s./usr/local/lib/python2.7/test/test_optparse.pyttest_bool_flicker_on_and_off*s (RRRTR#R$R%R&(((s./usr/local/lib/python2.7/test/test_optparse.pyR" s    t TestChoicecBs,eZdZdZdZdZRS(c CsGtdt|_|jjddddddddd d d gdS( NRSs-cR^RlRCReR}Rgtonettwotthree(RRR R(R((s./usr/local/lib/python2.7/test/test_optparse.pyRT0scCs*|jdddgidd6dgdS(Ns-cR(RRe(R+(R((s./usr/local/lib/python2.7/test/test_optparse.pyttest_valid_choice5s cCs|jdddgddS(Ns-ctfourtabcsEoption -c: invalid choice: 'four' (choose from 'one', 'two', 'three')(R=(R((s./usr/local/lib/python2.7/test/test_optparse.pyttest_invalid_choice:scCs^|jjddddddg|jjd}|j|jd|j|jddS( Ns-ds --defaultRgR,tfivetsixReRl(R RRR#RCR^(RR((s./usr/local/lib/python2.7/test/test_optparse.pyttest_add_choice_option?s (RRRTR+R.R1(((s./usr/local/lib/python2.7/test/test_optparse.pyR'/s   t TestCountcBseZdZdZdZdZdZdZdZdZ dZ d Z d Z d Z d Zd ZRS(c Cstdt|_tddddd|_|jj|j|jjddd dd|jjd d dd ddd ddS(NRSs-vR^RbR}R~s --verboseRCRcs-qs--quiett store_constRmi(RRR Rtv_optR(R((s./usr/local/lib/python2.7/test/test_optparse.pyRTGs cCs|jgidd6gdS(NR~(R+R(R((s./usr/local/lib/python2.7/test/test_optparse.pyROscCs!|jdgidd6gdS(Ns-viR~(R+(R((s./usr/local/lib/python2.7/test/test_optparse.pyttest_count_oneRscCs!|jdgidd6gdS(Ns-vvviR~(R+(R((s./usr/local/lib/python2.7/test/test_optparse.pyttest_count_threeUscCs'|jdddgidd6gdS(Ns-viR~(R+(R((s./usr/local/lib/python2.7/test/test_optparse.pyttest_count_three_apartXscCs$|jddgidd6gdS(Ns-vvvs --verbose=2iR~(R+(R((s./usr/local/lib/python2.7/test/test_optparse.pyttest_count_override_amount[scCs'|jdddgidd6gdS(Ns-vvvs --verbose=2s-qiR~(R+(R((s./usr/local/lib/python2.7/test/test_optparse.pyttest_count_override_quiet^scCs*|jddddgidd6gdS(Ns-vvvs --verbose=2s-qs-viR~(R+(R((s./usr/local/lib/python2.7/test/test_optparse.pyttest_count_overridingascCs*|jdddgidd6dgdS(Ns--quiett3s-viR~(R+(R((s./usr/local/lib/python2.7/test/test_optparse.pyttest_count_interspersed_argses cCs:|jj|jdddgidd6ddgdS(Ns--quietR;s-viR~(R tdisable_interspersed_argsR+(R((s./usr/local/lib/python2.7/test/test_optparse.pyttest_count_no_interspersed_argsjs  cCs|jddgddS(Ns-q3s-vsno such option: -3(R=(R((s./usr/local/lib/python2.7/test/test_optparse.pyttest_count_no_such_optionpscCs|jddgddS(Ns --quiet=3s-vs$--quiet option does not take a value(R=(R((s./usr/local/lib/python2.7/test/test_optparse.pyttest_count_option_no_valuesscCs1|jjdd|jgidd6gdS(NR~i(R RR+(R((s./usr/local/lib/python2.7/test/test_optparse.pyttest_count_with_defaultwscCs=|jjdd|jddddgidd6gdS(NR~is-vvvs --verbose=2s-qs-vi(R RR+(R((s./usr/local/lib/python2.7/test/test_optparse.pyttest_count_overriding_default{s(RRRTRR5R6R7R8R9R:R<R>R?R@RARB(((s./usr/local/lib/python2.7/test/test_optparse.pyR2Fs             tTestMultipleArgscBs5eZdZdZdZdZdZRS(c CsAtdt|_|jjdddddddd d d dS( NRSs-ps--pointR^RlRoiRCtfloatR}tpoint(RRR R(R((s./usr/local/lib/python2.7/test/test_optparse.pyRTscCs6|jddddddgid d 6ddgdS( NR[s-pt1s2.5s-4.3Rg?g@g333333RE(g?g@g333333(R+(R((s./usr/local/lib/python2.7/test/test_optparse.pyttest_nargs_with_positional_argss cCs0|jdddddgid d 6dgdS( Ns--points-1s2.5s-0Rgg@gRE(gg@g(R+(R((s./usr/local/lib/python2.7/test/test_optparse.pyttest_nargs_long_opts cCs |jddddgddS(Ns-ps1.0t2xs3.5s-option -p: invalid floating-point value: '2x'(R=(R((s./usr/local/lib/python2.7/test/test_optparse.pyttest_nargs_invalid_float_valuescCs|jdddgddS(Ns--points1.0s3.5s#--point option requires 3 arguments(R=(R((s./usr/local/lib/python2.7/test/test_optparse.pyttest_nargs_required_valuess(RRRTRGRHRJRK(((s./usr/local/lib/python2.7/test/test_optparse.pyRCs     tTestMultipleArgsAppendcBs5eZdZdZdZdZdZRS(c Cstdt|_|jjdddddddd d d |jjd d ddddddd d|jjddddd ddddS(NRSs-ps--pointR^RlRoiRCRDR}REs-fs--fooRiRcR[s-zs--zerot append_constRmi(ii(RRR R(R((s./usr/local/lib/python2.7/test/test_optparse.pyRTs  cCsC|jdddddddgidd6ddgd 6dgdS(Ns-ft4s-3Rs--fooRFt666REiiiiR[(ii(ii(R+R(R((s./usr/local/lib/python2.7/test/test_optparse.pyttest_nargs_appendscCs|jdgddS(Ns-f4,3s-f option requires 2 arguments(R=(R((s./usr/local/lib/python2.7/test/test_optparse.pyt!test_nargs_append_required_valuess cCs.|jddgidd6dgd6gdS(Ns--foo=3RNREiiR[(ii(R+R(R((s./usr/local/lib/python2.7/test/test_optparse.pyttest_nargs_append_simplescCs=|jdddddgidd6d d d gd 6gdS(Ns--zeros--fooR;RNs-zREiiiR[(ii(ii(ii(R+R(R((s./usr/local/lib/python2.7/test/test_optparse.pyttest_nargs_append_consts(RRRTRPRQRRRS(((s./usr/local/lib/python2.7/test/test_optparse.pyRLs    t TestVersioncBseZdZdZRS(cCsmtdtdd|_tj}z9tjjtjddtjd<|j dgdWd|tj(XdS( NRSRs %prog 0.1R[R\is --versionsbar 0.1 ( RRR R?RRRRtcurdirRJ(RR((s./usr/local/lib/python2.7/test/test_optparse.pyt test_versions   "cCs)tdt|_|jdgddS(NRSs --versionsno such option: --version(RRR R=(R((s./usr/local/lib/python2.7/test/test_optparse.pyttest_no_versions (RRRVRW(((s./usr/local/lib/python2.7/test/test_optparse.pyRTs tTestConflictingDefaultscBs)eZdZdZdZdZRS(s4Conflicting default values: the last one should win.c Cs1tdtdddddddg|_dS( NRs-vR^R|R}R~Ri(RRR (R((s./usr/local/lib/python2.7/test/test_optparse.pyRTscCs@|jjddddddd|jgidd6gdS(Ns-qR^RR}R~Ri(R RR+(R((s./usr/local/lib/python2.7/test/test_optparse.pyttest_conflict_defaultscCs@|jjddddddd|jgidd6gdS(Ns-qR^RR}R~R(R RRR+(R((s./usr/local/lib/python2.7/test/test_optparse.pyttest_conflict_default_nones(RRRRTRYRZ(((s./usr/local/lib/python2.7/test/test_optparse.pyRXs  tTestOptionGroupcBs>eZdZdZdZdZdZdZRS(cCstdt|_dS(NRS(RRR (R((s./usr/local/lib/python2.7/test/test_optparse.pyRTscCs\t|jd}|jj||jddddd|jdgidd6gdS( NtSpams--spamR^R|Rsspam spam spam spamitspam(RR tadd_option_groupRR+(Rtgroup((s./usr/local/lib/python2.7/test/test_optparse.pyt!test_option_group_create_instances cCs|j|jjdddS(Ns!not an OptionGroup instance: None(RLR R^R(R((s./usr/local/lib/python2.7/test/test_optparse.pyttest_add_group_no_groupscCs |j|jjddddS(Nsinvalid arguments(RLR R^R(R((s./usr/local/lib/python2.7/test/test_optparse.pyt test_add_group_invalid_argumentsscCsDt|jd}t|_|j|jj|fdtddS(NR\s"invalid OptionGroup (wrong parser)(RR RR9R^RR(RR_((s./usr/local/lib/python2.7/test/test_optparse.pyttest_add_group_wrong_parsers cCsX|jjddd}|jd|jddd|j|jjd|dS(NsGroup 2t descriptionsSome more optionstBacons--baconRCRc(R R^t set_titleRR/tget_option_group(RR_((s./usr/local/lib/python2.7/test/test_optparse.pyttest_group_manipulates   (RRRTR`RaRbRcRh(((s./usr/local/lib/python2.7/test/test_optparse.pyR[s      tTestExtendAddTypescBsKeZdZdZdefdYZdZdZdZRS(cCs]tdtd|j|_|jjdddddd|jjdd dd dd dS( NRSRs-aRCRR}Rs-fs--fileR(RRtMyOptionR RR(R((s./usr/local/lib/python2.7/test/test_optparse.pyRTs cCsTtjjtjr(tjtjn(tjjtjrPtjtjndS(N(RRtisdirRtTESTFNtrmdirtisfiletunlink(R((s./usr/local/lib/python2.7/test/test_optparse.pyttearDownsRjcBs:eZdZejdZejejZeedrsRCRRR[s%Options: -t TEST, --test=TEST foo (RRRRRQ(RR RO((s./usr/local/lib/python2.7/test/test_optparse.pyttest_callback_helpks (RRRTRRR(((s./usr/local/lib/python2.7/test/test_optparse.pyRDs  tTestCallbackExtraArgscBs#eZdZdZdZRS(cCsUtddddd|jddtfddd d d gg}td ||_dS( Ns-ps--pointR^RqRtiRCRR}tpointsRR(Rt process_tupleRcRR (RR(((s./usr/local/lib/python2.7/test/test_optparse.pyRT{s  cCs|j|d|j|tk|dkrB|j|dn|dkra|j|dntt||jd}t|j|jj |dS(Nis-ps1,2,3s--points4,5,6R}( R#R/RcR`tmapR~RARR}R(RRRRRtlenRC((s./usr/local/lib/python2.7/test/test_optparse.pyRs  cCs-|jdddgid d gd 6gdS( Ns-p1,2,3s--points4,5,6iiiiiiR(iii(iii(R+(R((s./usr/local/lib/python2.7/test/test_optparse.pyttest_callback_extra_argss(RRRTRR(((s./usr/local/lib/python2.7/test/test_optparse.pyRzs  tTestCallbackMeddleArgscBs,eZdZdZdZdZRS(c Cs\gtdddD]-}tt|ddd|jdd^q}td||_dS(NiiR^RqR}tthingsR(trangeRR,t process_nRR (RRR(((s./usr/local/lib/python2.7/test/test_optparse.pyRTsCcCst|d}|j}t||krE|jd||fn|jj|jg}|jt|d|!|j j||d|5dS(Nis$Expected %d arguments for %s option.i( RctrargsRR2RRR}RR`tlargs(RRRRRRoRR}((s./usr/local/lib/python2.7/test/test_optparse.pyRs cCs<|jddddddgid d gd6dd gdS( Ns-1R[s-3R\RtquxRii(sfoo(sbarsbazR(R+(R((s./usr/local/lib/python2.7/test/test_optparse.pyttest_callback_meddle_argsscCs-|jdddgidgd6dgdS(Ns-2R[s--Ri(sfoos--(R+(R((s./usr/local/lib/python2.7/test/test_optparse.pyt#test_callback_meddle_args_separators (RRRTRRR(((s./usr/local/lib/python2.7/test/test_optparse.pyRs  tTestCallbackManyArgscBs#eZdZdZdZRS(c Csjtddddddd|jddtd d dddd d|jdd g}td ||_dS(Ns-as--appleR^RqRoiRCRs-bs--bobiRcR(Rt process_manyRR (RR(((s./usr/local/lib/python2.7/test/test_optparse.pyRTs cCs|dkr|j|dn]|dkr>|j|dn>|dkr]|j|dn|d kr||j|dndS(Ns-aR[R\s--appletdingtdongs-biiis--bobifi*i(sfoosbar(RR(iii(ifi*i(R#(RRRRR((s./usr/local/lib/python2.7/test/test_optparse.pyRs    cCsO|jddddddddd d d d d dgidd6dd6gdS(Ns-aR[R\s--appleRRs-bRFt2R;s--bobs-666Rt0R|tbob(R+R(R((s./usr/local/lib/python2.7/test/test_optparse.pyttest_many_argss (RRRTRR(((s./usr/local/lib/python2.7/test/test_optparse.pyRs  tTestCallbackCheckAbbrevcBs#eZdZdZdZRS(cCs/t|_|jjdddd|jdS(Ns --foo-barR^Rq(RR Rt check_abbrev(R((s./usr/local/lib/python2.7/test/test_optparse.pyRTs cCs|j|ddS(Ns --foo-bar(R#(RRRRR ((s./usr/local/lib/python2.7/test/test_optparse.pyRscCs|jdgigdS(Ns--foo(R+(R((s./usr/local/lib/python2.7/test/test_optparse.pyttest_abbrev_callback_expansions(RRRTRR(((s./usr/local/lib/python2.7/test/test_optparse.pyRs  tTestCallbackVarArgscBsGeZdZdZdZdZdZdZdZRS(c Csstdddddddtdd d dd td d d dd|jddg}tdtd||_dS(Ns-aRCRcRoiR}Rs-bR^R|RWs-cs --callbackRqtcRSR(Rt variable_argsRRR (RR(((s./usr/local/lib/python2.7/test/test_optparse.pyRTs  cCs|j|dkg}|j}x|r|d}|d dkrWt|dks|d dkrt|dkr|ddkrPq%|j||d=q%Wt|j|j|dS(Niis--iR(R/RRRRRRR}(RRRRR Rtarg((s./usr/local/lib/python2.7/test/test_optparse.pyRs   "2  cCsA|jdddddgid d6dd 6ddgd 6gdS( Ns-a3s-5s --callbackR[R\iiRRWR(ii(R+R(R((s./usr/local/lib/python2.7/test/test_optparse.pyttest_variable_argsscCsJ|jddddddgidd6td6dddgd 6dgdS( Ns-ct37s--txxxs-bthelloRRWR(R+RR(R((s./usr/local/lib/python2.7/test/test_optparse.pyt%test_consume_separator_stop_at_options  cCsG|jdddddgidd6dd6dddgd6dgdS( NRs-cR[RR\RRWR(R+R(R((s./usr/local/lib/python2.7/test/test_optparse.pyt%test_positional_arg_and_variable_argss  cCs8|jdddgidd6td6dgd6gdS(Ns-cR[s-bRRWR(R+RR(R((s./usr/local/lib/python2.7/test/test_optparse.pyttest_stop_at_optionscCs |jddddgddS(Ns-cR;s-5s-asno such option: -5(R=(R((s./usr/local/lib/python2.7/test/test_optparse.pyttest_stop_at_invalid_options( RRRTRRRRRR(((s./usr/local/lib/python2.7/test/test_optparse.pyRs      t ConflictBasecBseZdZdZRS(c Cs@tddddddddg}td td ||_dS( Ns-vs --verboseR^RbR}R~Rsincrement verbosityRSR(RRRR (RR(((s./usr/local/lib/python2.7/test/test_optparse.pyRT s cCsd|j_dS(Ni(Rt show_version(RRRRR ((s./usr/local/lib/python2.7/test/test_optparse.pyRs(RRRTR(((s./usr/local/lib/python2.7/test/test_optparse.pyR s t TestConflictcBs2eZdZdZdZdZdZRS(s9Use the default conflict resolution for Optik 1.2: error.cCs]|j|d idd6|jd6dd6td}|j|jd|j|jd dS( Ns-vs --versionRqR^s show versionRs5option -v/--version: conflicting option string(s): -vs conflicting option string(s): -vs -v/--version(s-vs --version(R9RR R#Rt option_id(RR3R7((s./usr/local/lib/python2.7/test/test_optparse.pytassertTrueconflict_errors  cCs|j|jjdS(N(RR R(R((s./usr/local/lib/python2.7/test/test_optparse.pyttest_conflict_error!scCs&t|jd}|j|jdS(NsGroup 1(RR RR(RR_((s./usr/local/lib/python2.7/test/test_optparse.pyttest_conflict_error_group$scCs#|j|jjddtddS(NR[s'invalid conflict_resolution value 'foo'(sfoo(R9R tset_conflict_handlerRR(R((s./usr/local/lib/python2.7/test/test_optparse.pyttest_no_such_conflict_handler(s(RRRRRRR(((s./usr/local/lib/python2.7/test/test_optparse.pyRs   tTestConflictResolvecBs>eZdZdZdZdZdZdZRS(c CsItj||jjd|jjddddd|jdddS(Ntresolves-vs --versionR^RqRs show version(RRTR RRR(R((s./usr/local/lib/python2.7/test/test_optparse.pyRT/s cCs|jjd}|jjd}|jjd}|j||k|j||k |j|jdg|j|jdg|j|jdg|j|jg|j|jdgdS(Ns-vs --verboses --version(R RR/R#RR(RR4t verbose_optt version_opt((s./usr/local/lib/python2.7/test/test_optparse.pyttest_conflict_resolve5scCs|jdgddS(Ns-hs}Options: --verbose increment verbosity -h, --help show this help message and exit -v, --version show version (RJ(R((s./usr/local/lib/python2.7/test/test_optparse.pyttest_conflict_resolve_helpBs cCs(|jdgidd6dd6gdS(Ns-vR~iR(R+R(R((s./usr/local/lib/python2.7/test/test_optparse.pyttest_conflict_resolve_short_optJs cCs!|jdgidd6gdS(Ns --verboseiR~(R+(R((s./usr/local/lib/python2.7/test/test_optparse.pyttest_conflict_resolve_long_optOs  cCs+|jddgidd6dd6gdS(Ns --verboses --versioniR~R(R+(R((s./usr/local/lib/python2.7/test/test_optparse.pyttest_conflict_resolve_long_optsTs(RRRTRRRRR(((s./usr/local/lib/python2.7/test/test_optparse.pyR.s     tTestConflictOverridecBs,eZdZdZdZdZRS(c Csvtdt|_|jjd|jjddddddd d |jjdddd d d ddd ddS(NRSRs-ns --dry-runR^R|R}tdry_runRsdon't do anythingR3Rmi*s dry run mode(RRR RR(R((s./usr/local/lib/python2.7/test/test_optparse.pyRTZs cCsB|jjd}|j|jdg|j|jdgdS(Ns --dry-runs-n(R RR#RR(RR((s./usr/local/lib/python2.7/test/test_optparse.pyttest_conflict_override_optsdscCs|jdgddS(Ns-hsXOptions: -h, --help show this help message and exit -n, --dry-run dry run mode (RJ(R((s./usr/local/lib/python2.7/test/test_optparse.pyttest_conflict_override_helpis cCs!|jdgidd6gdS(Ns-ni*R(R+(R((s./usr/local/lib/python2.7/test/test_optparse.pyttest_conflict_override_argsps  (RRRTRRR(((s./usr/local/lib/python2.7/test/test_optparse.pyRYs  sSUsage: bar.py [options] Options: -a APPLE throw APPLEs at basket -b NUM, --boo=NUM shout "boo!" NUM times (in order to frighten away all the evil spirits that cause trouble and mayhem) --foo=FOO store FOO in the foo list for later fooing -h, --help show this help message and exit sSUsage: bar.py [options] Options: -a APPLE throw APPLEs at basket --boo=NUM, -b NUM shout "boo!" NUM times (in order to frighten away all the evil spirits that cause trouble and mayhem) --foo=FOO store FOO in the foo list for later fooing --help, -h show this help message and exit sWUsage ===== bar.py [options] Options ======= -a APPLE throw APPLEs at basket --boo=NUM, -b NUM shout "boo!" NUM times (in order to frighten away all the evil spirits that cause trouble and mayhem) --foo=FOO store FOO in the foo list for later fooing --help, -h show this help message and exit s}Usage: bar.py [options] Options: -a APPLE throw APPLEs at basket -b NUM, --boo=NUM shout "boo!" NUM times (in order to frighten away all the evil spirits that cause trouble and mayhem) --foo=FOO store FOO in the foo list for later fooing -h, --help show this help message and exit s~Usage: bar.py [options] Options: -a APPLE throw APPLEs at basket -b NUM, --boo=NUM shout "boo!" NUM times (in order to frighten away all the evil spirits that cause trouble and mayhem) --foo=FOO store FOO in the foo list for later fooing -h, --help show this help message and exit tTestHelpcBskeZdZdZdZdZdZdZdZdZ dZ d Z d Z RS( cCs|jd|_dS(NiP(t make_parserR (R((s./usr/local/lib/python2.7/test/test_optparse.pyRTsc Cstddddddddd td d dd dd ddddtdddddddddg}tj$}t||dR((s./usr/local/lib/python2.7/test/test_optparse.pytassertHelpEqualss cCs|jtdS(N(Rt_expected_help_basic(R((s./usr/local/lib/python2.7/test/test_optparse.pyt test_helpscCs!|jjd|jtdS(NsUsage: %prog [options](R t set_usageRR(R((s./usr/local/lib/python2.7/test/test_optparse.pyttest_help_old_usagescCs d|jj_|jtdS(Ni(R Rt short_firstRt_expected_help_long_opts_first(R((s./usr/local/lib/python2.7/test/test_optparse.pyttest_help_long_opts_firstscCs?tj-}d|dolé! Options: -h, --help show this help message and exit (RRR R(RR((s./usr/local/lib/python2.7/test/test_optparse.pyttest_help_unicode_descriptions  cCs|jjdt|jdd}|jddddd|jj|d }|j|d |j_|j|d dS( Ns`This is the program description for %prog. %prog has an option group as well as single options.sDangerous OptionssZCaution: use of these options is at your own risk. It is believed that some of them bite.s-gR^R|Rs Group option.sTUsage: bar.py [options] This is the program description for bar.py. bar.py has an option group as well as single options. Options: -a APPLE throw APPLEs at basket -b NUM, --boo=NUM shout "boo!" NUM times (in order to frighten away all the evil spirits that cause trouble and mayhem) --foo=FOO store FOO in the foo list for later fooing -h, --help show this help message and exit Dangerous Options: Caution: use of these options is at your own risk. It is believed that some of them bite. -g Group option. s Please report bugs to /dev/null.s" Please report bugs to /dev/null. (R tset_descriptionRRR^Rtepilog(RR_R((s./usr/local/lib/python2.7/test/test_optparse.pyttest_help_description_groupss     ( RRRTRRRRRRRRRR(((s./usr/local/lib/python2.7/test/test_optparse.pyRs       tTestMatchAbbrevcBseZdZdZRS(cCs9|jtdidd6dd6dd6dd6ddS(Ns--fs--fozs--foos--fie(R#R R(R((s./usr/local/lib/python2.7/test/test_optparse.pyttest_match_abbrevEs    cCsDd}idd6dd6dd6}|jt||fdtddS(Ns--fs--fozs--foos--fies,ambiguous option: --f (--fie, --foo, --foz?)(RR9R R (RRtwordmap((s./usr/local/lib/python2.7/test/test_optparse.pyttest_match_abbrev_errorMs (RRRR(((s./usr/local/lib/python2.7/test/test_optparse.pyRDs tTestParseNumbercBs,eZdZdZdZdZRS(cCs<t|_|jjddt|jjddtdS(Ns-nRCs-l(RR RRctlong(R((s./usr/local/lib/python2.7/test/test_optparse.pyRTVs cCsT|jtdtfittjd|jtdtfittjddS(NRs!invalid literal for int().*: '?'?t0xOoopss)invalid literal for long().*: '?0xOoops'?(R9RRcRtretcompileR(R((s./usr/local/lib/python2.7/test/test_optparse.pyttest_parse_num_fail[scCs|jtdtd|jtdtd|jtdtd|jtdtd|jtd td |jtd td dS( NRit0x10it0XAl t010lt0b11it0bl(R#RRcR(R((s./usr/local/lib/python2.7/test/test_optparse.pyttest_parse_num_okes cCs|jddddgidd6dd6g|jdd d gid d6d d6g|jd gd|jdgd|jddgddS(Ns-nRs-lt0x20i*Ri tlt0b0101s-l010iis-n008s'option -n: invalid integer value: '008's-l0b0123s/option -l: invalid long integer value: '0b0123't0x12xs.option -l: invalid long integer value: '0x12x'(R+R=(R((s./usr/local/lib/python2.7/test/test_optparse.pyttest_numeric_optionsms  (RRRTRRR(((s./usr/local/lib/python2.7/test/test_optparse.pyRUs  cCstjtdS(N(Rt run_unittestR(((s./usr/local/lib/python2.7/test/test_optparse.pyt test_mainzst__main__iiiQ(HR?RRRRDtunittestRRRtoptparseRRRRRRRR R R R R RRCRR.t ExceptionRRtTestCaseRRRR{RRRRRRRRRR"R'R2RCRLRTRXR[RiRzRRRRRRRRRRRRRRRRRRRR(((s./usr/local/lib/python2.7/test/test_optparse.pyt sp      L |O" 3*N#:"+6 5 +'  !{%