m %UIc@s\dkZdkZdkZdkZdklZdklZdklZdk l Z l Z l Z l Z lZlZlZlZlZlZlZlZlZlZlZyeefWnej odZ\ZZnXdefdYZd efd YZd eifd YZ d e fdYZ!de fdYZ"de fdYZ#de fdYZ$hdd<dd<ddd<dddde fd?YZ8d@e fdAYZ9dBe fdCYZ:dDe fdEYZ;dFe fdGYZ<dHe<fdIYZ=dJe<fdKYZ>dLe fdMYZ?dNZ@dOZAdPZBdQZCdRe fdSYZDdTe fdUYZEdVZFdWZGdXZHeIdYjoeiJndS([N(sStringIO(spprint(s test_support(s make_optionsOptionsIndentedHelpFormattersTitledHelpFormatters OptionParsersOptionContainers OptionGroups SUPPRESS_HELPsSUPPRESS_USAGEs OptionErrorsOptionConflictErrorsBadOptionErrorsOptionValueErrorsValuess _match_abbreviitInterceptedErrorcBs#tZddddZdZRS(NcCs||_||_||_dS(N(t error_messagetselft exit_statust exit_message(RRRR((t//data/zmath/lib/python2.4/test/test_optparse.pyt__init__!s  cCs|ip|ipdS(Nsintercepted error(RRR(R((Rt__str__)s(t__name__t __module__tNoneRR(((RR stInterceptingOptionParsercBs tZdddZdZRS(NicCstd|d|dS(NRR(Rtstatustmsg(RR R ((Rtexit-scCstd|dS(NR(RR (RR ((Rterror0s(RR R RR(((RR ,stBaseTestcBsDtZdZdZdZdddZdZdZRS(NcCsb|ii|\}}t|}|i||dt |i||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.N( Rtparsert parse_argstargstoptionstpositional_argstvarstoptdictt assertEqualt expected_optstlocalstexpected_positional_args(RRRRRRR((Rt assertParseOK5s    cCs|djo f}n|djo h}ny|||Wn?|j o3}t|}|i ||dt |SnX|i dt 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_output -- output we expect to see Returns the exception raised for further testing. sjexpected exception message: '''%(expected_message)s''' actual exception message: '''%(actual_message)s''' snexpected exception %(expected_exception)s not raised called %(func)r with args %(args)r and kwargs %(kwargs)r N( RR tkwargstfunctexpected_exceptionterrtstrtactual_messageRRtexpected_messageRtfail(RRRRRR#R R"((Rt assertRaisesSs       cCsPy|ii|Wn(tj o}|i|i|nX|i ddS(s Assert the parser fails with the expected message. Caller must ensure that self.parser is an InterceptingOptionParser. sexpected parse failureN( RRRt cmdline_argsRR RRtexpected_outputt assertFalse(RR&R'R ((RtassertParseFails icCsti}y@z tt_|ii|Wdtii}|t_XWnKt j o?}|i |||i |i||i |i|nX|iddS(s7Assert the parser prints the expected output on stdout.Nsexpected parser.exit()(tsyststdoutt save_stdouttStringIORRRR&tgetvaluetoutputRR RR'Rtexpected_statusRtexpected_errorR((RR&R'R0R1R,R R/((Rt assertOutputs  cGs|i||dt|dS(s4Assert that TypeError is raised when executing func.N(RR%RRR t TypeErrorR#(RRR#R((RtassertTypeErrorscCs@|i}||jo#|id|d|dndS(Nshelp text failure; expected: "s "; got: "s" (Rt format_helpt actual_helpt expected_helpRtfailureException(RRR7R6((Rt assertHelps  ( RR RR%R)R R2R4R9(((RR4s   1  tTestOptionCheckscBstZdZghdZdZdZdZdZdZdZ d Z d Z d Z d Z d ZdZdZdZdZdZdZdZdZdZRS(NcCstdt|_dS(Ntusage(t OptionParsertSUPPRESS_USAGERR(R((RtsetUpscCs|it||t|dS(N(RR%t make_optionRRt OptionErrorR#(RR#RR((RtassertOptionErrorscCs|itddS(Ns+at least one option string must be supplied(RR4R?(R((Rttest_opt_string_emptys cCs|iddgdS(Ns?invalid option string 'b': must be at least two characters longtb(RRA(R((Rttest_opt_string_too_shorts cCs|iddgdS(NsOinvalid short option string '--': must be of the form -x, (x any non-dash char)s--(RRA(R((Rttest_opt_string_short_invalids cCs|iddgdS(NsJinvalid long option string '---': must start with --, followed by non-dashs---(RRA(R((Rttest_opt_string_long_invalids cCs,|iddghdd<dd<dS(Ns.option -b: invalid keyword arguments: bar, foos-btfootbar(RRAR (R((Rttest_attr_invalids cCs#|iddghdd<dS(Ns option -b: invalid action: 'foo's-btactionRG(RRA(R((Rttest_action_invalids cCsB|iddghdd<|iddghdt<dS(Ns%option -b: invalid option type: 'foo's-bttypeRGs'option -b: invalid option type: 'tuple'(RRAttuple(R((Rttest_type_invalids  cCs,|iddghdd<dd<dS(Ns4option -b: must not supply a type for action 'count's-bRJtcountRLtint(RRA(R((Rttest_no_type_for_actions cCs&|idddghdd<dS(Ns@option -b/--bad: must supply a list of choices for type 'choice's-bs--badRLtchoice(RRA(R((Rttest_no_choices_lists cCsBtdi}|id|ddghdd<dd<dS( NtsBoption -b/--bad: choices must be a list of strings ('%s' supplied)s-bs--badRLRRtchoicess bad choices(RLRttypenameRRA(RRV((Rttest_bad_choices_lists  cCs,|iddghdd<dd<dS(Ns1option -b: must not supply choices for type 'int's-bRLRPRUtbad(RRA(R((Rttest_no_choices_for_types cCs,|iddghdd<dd<dS(Ns:option -b: 'const' must not be supplied for action 'store's-bRJtstoretconsti(RRA(R((Rttest_no_const_for_actions cCs,|iddghdd<dd<dS(Ns:option -b: 'nargs' must not be supplied for action 'count's-bRJROtnargsi(RRA(R((Rttest_no_nargs_for_actions cCs,|iddghdd<dd<dS(Ns'option -b: callback not callable: 'foo's-bRJtcallbackRG(RRA(R((Rttest_callback_not_callable s cCsdS(N((R((RtdummyscCs8|iddghdd<d|i<dd<dS(NsAoption -b: callback_args, if supplied, must be a tuple: not 'foo's-bRJR_t callback_argsRG(RRARa(R((Rttest_callback_args_no_tuples cCs8|iddghdd<d|i<dd<dS(NsBoption -b: callback_kwargs, if supplied, must be a dict: not 'foo's-bRJR_tcallback_kwargsRG(RRARa(R((Rttest_callback_kwargs_no_dicts cCs,|iddghdd<dd<dS(Ns<option -b: callback supplied ('foo') for non-callback options-bRJRZR_RG(RRA(R((Rttest_no_callback_for_action"s cCs,|iddghdd<dd<dS(Ns9option -b: callback_args supplied for non-callback options-bRJRZRbRG(RRA(R((Rt test_no_callback_args_for_action(s cCs,|iddghdd<dd<dS(Ns;option -b: callback_kwargs supplied for non-callback options-bRJRZRdRG(RRA(R((Rt"test_no_callback_kwargs_for_action.s (RR R>RARBRDRERFRIRKRNRQRSRWRYR\R^R`RaRcReRfRgRh(((RR:s,                    tTestOptionParsercBsbtZdZdZdZdZdZdZdZdZ d Z d Z RS( Nc CsWt|_|iidddddddd|iid d d dd dddS( Ns-vs --verboses-ns--noisyRJt store_truetdesttverboses-qs--quiets--silentt store_false(R<RRt add_option(R((RR>5s  cCs|i|iidddS(Nsnot an Option instance: None(RR4RRnR (R((Rttest_add_option_no_Option<scCs |i|iiddddS(Nsinvalid arguments(RR4RRnR (R((Rt!test_add_option_invalid_arguments@scCs|iid}|it|t|i|iddg|i|i ddg|i|i d|i|i ddS(Ns-vs-ns --verboses--noisyRjRl( RRt get_optiontopt1tassert_t isinstancetOptionRt _short_optst _long_optsRJRk(RRr((Rttest_get_optionDs cCs||iid}|iid}|iid}|iid}|i||jo|jo |jndS(Ns-vs --verboses-ns--noisy(RRRqRrtopt2topt3topt4Rs(RR{RrRzRy((Rttest_get_option_equalsLs cCs6|i|iid|i|iiddS(Ns-vs --verbose(RRsRt has_option(R((Rttest_has_optionSscCs|i|iiddj|i|iiddj|i|iiddj|i|iiddj|i|iid|i|iid|i|iid|i|iid|i|iid|i|iiddS(Ns-vs --verboses-ns--noisys-qs--silent(RRsRRqR tfailIfR}(R((Rtassert_removedWscCs|iid|idS(Ns-n(RRt remove_optionR(R((Rttest_remove_short_optescCs|iid|idS(Ns --verbose(RRRR(R((Rttest_remove_long_optiscCs#|i|iiddtddS(NRGsno such option 'foo'(sfoo(RR%RRR t ValueError(R((Rttest_remove_nonexistentms( RR R>RoRpRxR|R~RRRR(((RRi4s         tTestOptionValuescBstZdZdZRS(NcCsdS(N((R((RR>rscCst}|it|h|i|h|i|hdd<|i|dhdd<dd<}td|}|it|||i|||i|hdd<|i|h|i|d|i|gdS(NRGRHRTtbazi*tdefaults(tValuestvaluesRRRtassertNotEqualtdict(RRR((Rt test_basicsus (RR R>R(((RRqs tTestTypeAliasescBstZdZdZRS(NcCst|_dS(N(R<RR(R((RR>scCs|iiddt|iiddt|iiddd|i|iidid|i|iidid|i|iididdS(Ns-xRLs-ss-tR!RPtstring(RRRnRPR!t assertEqualsRqRL(R((Rttest_type_aliasess (RR R>R(((RRs tstmi<thtdicCsoy=|diot|Snt|d t|dSWn+tj o}td||fnXdS(Nisoption %s: invalid duration: %r(tvaluetisdigitRPt _time_unitsRt IndexErrortOptionValueErrortopt(toptionRRR((Rt_check_durations tDurationOptioncBs1tZeidZeieiZeeds cCs |i|ii|idS(N(RRRtget_default_valuesR(R((Rttest_basic_defaultsscCs[|iidddd|iihdd<dd<|i|ii|idS(NRi*Ri(RRt set_defaultsRtupdateRR(R((Rttest_mixed_defaults_posts"cCs|iidddd|iiddd|iid|iihdd<dd<|i|ii|i|iid|iiddd|iihdd<|i|ii|idS( Ntxtbarftytblahs-xRtfrobs-y( RRRRnRRRRRR (R((Rttest_mixed_defaults_pres"cCst|i_|iiddddd|iiddddd|iidd |iihd d<d d <dd <|i|ii |i|ii t |iihd d<d d<dd <|i|ii |idS(Ns-dRLRRi,s-et6mRt42Rteihi*( RRRt option_classRnRRRRRtset_process_default_valuestFalse(R((Rttest_process_defaults ++(RR R>RRRR(((RRs     t TestProgNamecBs2tZdZdZdZdZdZRS(s] Test that %prog expands to the right thing in usage, version, and help strings. cCs|i|i|dS(N(RRRt get_usagetexpected_usage(RRR((Rt assertUsagescCs|i|i|dS(N(RRRt get_versiontexpected_version(RRR((Rt assertVersionscCsti}zstiidddtids   cCs<|iiddddd|i|i|i|idS(Ns-fs--fileRsfoo.txtthelp(RRRnRR9R(R((Rttest_option_defaults cCsI|iiddd|i|iidd|i|i|idS(Ns-fs--fileRtfilesfoo.txt(RRRnRt set_defaultR9R(R((Rttest_parser_default_1s cCsI|iiddd|i|iidd|i|i|idS(Ns-fs--fileRRsfoo.txt(RRRnRRR9R(R((Rttest_parser_default_2s cCs6|iiddd|i|i|i|idS(Ns-fs--fileR(RRRnRR9R(R((Rttest_no_default#s cCs<|iiddddd|i|i|i|idS(Ns-fs--fileRR(RRRnR RR9R(R((Rttest_default_none_1(s cCsI|iiddd|i|iidd|i|i|idS(Ns-fs--fileRR(RRRnRRR R9R(R((Rttest_default_none_2.s cCsP|iidddd|iidd|id}|i|i|dS(Ns-ps--probRs1blow up with probability PROB [default: %default]tprobf0.42999999999999999sF -p PROB, --prob=PROB blow up with probability PROB [default: 0.43] (RRRnRRR7R9(RR7((Rttest_float_default4s   cCsH|iiddddddd|ii_|i|i|idS(Ns-fs--fileRsfoo.txtRs#read from FILE [default: *DEFAULT*]s *DEFAULT*(RRRnt formattert default_tagR9R(R((Rttest_alt_expand=s  cCsR|iiddddddd|ii_|id}|i|i|dS(Ns-fs--fileRsfoo.txtRsread from %default files0 -f FILE, --file=FILE read from %default file ( RRRnR RRRR7R9(RR7((Rttest_no_expandDs   ( RR R>RRRRRRRRR(((RRs        t TestStandardcBstZdZdZdZdZdZdZdZdZ d Z d Z d Z d Z d ZdZdZdZdZdZdZdZdZdZdZdZdZdZRS(NcCsXtdddtddddddtd d d g}td td ||_dS(Ns-aRLRs-bs--booRPRktboos--fooRJtappendR;t option_list(R?RR R=RR(RR((RR>Qs< cCs|idgddS(Ns-as-a option requires an argument(RR)(R((Rttest_required_valueYscCs|iddgddS(Ns-bt5xs&option -b: invalid integer value: '5x'(RR)(R((Rttest_invalid_integer\scCs|idgddS(Ns--boo13sno such option: --boo13(RR)(R((Rttest_no_such_option`scCs|idgddS(Ns--boo=x5s)option --boo: invalid integer value: 'x5'(RR)(R((Rttest_long_invalid_integercs cCs2|ighdd<dd<ddRRRRRRRRRRRRRRRRRRRRRRRRR(((RRPs4                         tTestBoolcBs5tZdZdZdZdZdZRS(Nc CsRtddddddddtd d dd ddg}td ||_dS( Ns-vs --verboseRJRjRkRlRRTs-qs--quietRmR(R?RR<RR(RR((RR>scCs |ighddR RRR(((RR s    t TestChoicecBs,tZdZdZdZdZRS(Nc CsGtdt|_|iiddddddddd d d gdS( NR;s-cRJRZRLRRRkRUtonettwotthree(R R=RRRn(R((RR>scCs,|idddghddRRR(((RRs   t TestCountcBstZdZdZdZdZdZdZdZdZ d Z d Z d Z d Z d ZdZRS(Nc Cstdt|_tddddd|_|ii|i|iiddd dd|iid d dd ddd ddS(NR;s-vRJRORkRls --verboseRLRPs-qs--quiett store_constR[i(R R=RRR?tv_optRn(R((RR>s cCs |ighddRRR R!R"R#R$R&R(R)R*R+R,(((RRs             tTestMultipleArgscBs5tZdZdZdZdZdZRS(Nc CsAtdt|_|iidddddddd d d dS( NR;s-ps--pointRJRZR]iRLtfloatRktpoint(R R=RRRn(R((RR>IscCs8|iddddddghdd R1R2R4R5(((RR-Hs     tTestMultipleArgsAppendcBs,tZdZdZdZdZRS(Nc Csltdt|_|iidddddddd d d |iid d ddddddd ddS(NR;s-ps--pointRJRZR]iRLR.RkR/s-fs--fooRiRPRG(R R=RRRn(R((RR>bs cCsG|idddddddghdd<d ddgR9R:R;(((RR6as   t TestVersioncBstZdZdZRS(NcCsmtdtdd|_ti}z9tii ti ddtid<|i dgdWd|ti(XdS( NR;Rs %prog 0.1RGRHis --versionsbar 0.1 ( R R=RRR*RRRRRtcurdirR2(RR((Rt test_versionxs  "cCs)tdt|_|idgddS(NR;s --versionsno such option: --version(R R=RRR)(R((Rttest_no_versions (RR R>R?(((RR<ws tTestConflictingDefaultscBs)tZdZdZdZdZRS(s4Conflicting default values: the last one should win.c Cs1tdtdddddddg|_dS( NRs-vRJRjRkRlRi(R<R?RR(R((RR>scCsB|iiddddddd|ighddRARB(((RR@s   tTestOptionGroupcBs>tZdZdZdZdZdZdZRS(NcCstdt|_dS(NR;(R<R=RR(R((RR>scCs^t|id}|ii||iddddd|idghddRIRJRKRLRQ(((RRCs      tTestExtendAddTypescBsBtZdZdefdYZdZdZdZRS(NcCs]tdtd|i|_|iidddddd|iidd dd dd dS( NR;Rs-aRLRRkRs-fs--fileR(R R=RtMyOptionRRnR (R((RR>s RScBs:tZdZeidZeieiZeedRuRSR]R^Ra(((RRRs    tTestExtendAddActionscBs9tZdZdefdYZdZdZRS(Nc Cs=|iddddddddg}td ||_dS( Ns-as--appleRJtextendRLRRktappleR(RRSRR<R(RR((RR>sRScBs8tZeidZeidZeidZdZRS(NRccCs\|djo,|id}|i|gi|n ti |||||||dS(NRct,( RJRtsplittlvalueRt ensure_valueRkRcRut take_actionRRR(RRJRkRRRRRg((RRis  (sextend(sextend(sextend(RR RutACTIONSt STORE_ACTIONSt TYPED_ACTIONSRi(((RRSs   cCs/|iddghddddgRuRSRmRn(((RRbs  t TestCallbackcBs,tZdZdZdZdZRS(Nc Cs^tddddd|itddddd|idddd g}td ||_dS( Ns-xRJR_s-fs--fileRLRRktfilenameR(R?R Rt process_optRR<R(RR((RR>s cCsJ|djo|i|idg|i|ig|i||ij|i|dj|it |i hdd<d|i _ n|djo|i|idg|i|idg|i||ij|i|d|it |i hdd<dd<t|i |i|n|id|dS( Ns-xRpi*s--files-fRGRs!Unknown option %r in process_opt.(RRRRRvRwRstparser_RRR RRRtsetattrRkR$(RRRRRr((RRqs " +cCs/|iddghdd<dd/sRLRRRGs%options: -t TEST, --test=TEST foo (R<R=RRRnR7RR9(RRR7((Rttest_callback_help(s  (RR R>RqRtRv(((RRos  tTestCallbackExtraArgscBs#tZdZdZdZRS(NcCsUtddddd|iddtfddd d d gg}td ||_dS( Ns-ps--pointRJR_RbiRLRRktpointsRR(R?Rt process_tupleRPRR<R(RR((RR>8s  cCs|i|d|i|tj|djo|i|dn"|djo|i|dntt ||i d}t |i |ii|dS(Nis-ps1,2,3s--points4,5,6Re(RRtlenRsRLRPRRRMtmapRftgetattrRrRRRkR(RRRRRrRzRL((RRy?s  c Cs/|idddghdd d gRyR}(((RRw7s  tTestCallbackMeddleArgscBs,tZdZdZdZdZRS(Nc Csdg}tdddD].}|tt|ddd|iddq~}td||_ dS(NiiRJR_RktthingsR( t_[1]trangeRR?R!Rt process_nRR<R(RRRR((RR>Qs2cCst|d}|i}t||jo|id||fn|ii |i g}|i t |d|!|ii ||d|5dS(Nis$Expected %d arguments for %s option.i(RPRR]RrtrargsRzRR$RRhRRkRRMtlargs(RRRRRrR]RRk((RRXs c Cs>|iddddddghdd d gRRR(((RR~Ps  tTestCallbackManyArgscBs#tZdZdZdZRS(Nc Csjtddddddd|iddtd d dddd d|idd g}td ||_dS(Ns-as--appleRJR_R]iRLRs-bs--bobiRPR(R?Rt process_manyRR<R(RR((RR>ns'cCs|djo|i|dnd|djo|i|dnC|djo|i|dn"|d jo|i|dndS(Ns-aRGRHs--appletdingtdongs-biiis--bobifi*i(sfoosbar(RR(iii(ifi*i(RRRR(RRRRRr((RRus    cCsS|iddddddddd d d d d dghdd<ddRR(((RRms  tTestCallbackCheckAbbrevcBs#tZdZdZdZRS(NcCs/t|_|iidddd|idS(Ns --foo-barRJR_(R<RRRnt check_abbrev(R((RR>s cCs|i|ddS(Ns --foo-bar(RRR(RRRRR((RRscCs|idghgdS(Ns--foo(RR(R((Rttest_abbrev_callback_expansions(RR R>RR(((RRs  tTestCallbackVarArgscBsGtZdZdZdZdZdZdZdZRS(Nc Csstdddddddtdd d dd td d d dd|iddg}tdtd||_dS(Ns-aRLRPR]iRkRs-bRJRjRCs-cs --callbackR_tcR;R(R?Rt variable_argsRR R=R(RR((RR>s? cCs|i|djd}g}|i}x|o|d}|d djot|djp5|d djo)t|djo|ddjoPq+|i ||d=q+Wt |i |i |dS(Niis--iR(RRsRR tdoneRRtargRzRRsRRRk(RRRRRRRR((RRs  Y  cCsG|idddddghdd <d d<d ddg|idddghdd<dt<ddgRRRRRR(((RRs      t ConflictBasecBstZdZdZRS(Nc Cs@tddddddddg}td td ||_dS( Ns-vs --verboseRJRORkRlRsincrement verbosityR;R(R?RR R=RR(RR((RR>s cCsd|i_dS(Ni(RRt show_version(RRRRR((RRs(RR R>R(((RRs t TestConflictcBs2tZdZdZdZdZdZRS(s9Use the default conflict resolution for Optik 1.2: error.cCsc|i|d hdd<d|i<ddtZdZdZdZdZdZdZRS(Nc CsIti||iid|iiddddd|idddS(Ntresolves-vs --versionRJR_Rs show version(RR>RRRRnR(R((RR>s cCs|iid}|iid}|iid}|i||j|i||j |i|idg|i|i dg|i|idg|i|i g|i|idgdS(Ns-vs --verboses --version( RRRqRt verbose_optt version_optRsRRwRv(RRRR((Rttest_conflict_resolvescCs|idgddS(Ns-hs}options: --verbose increment verbosity -h, --help show this help message and exit -v, --version show version (RR2(R((Rttest_conflict_resolve_helps cCs,|idghdd<ddRRRRR(((RRs     tTestConflictOverridecBs,tZdZdZdZdZRS(Nc Csvtdt|_|iid|iiddddddd d |iidddd d d ddd ddS(NR;Rs-ns --dry-runRJRjRktdry_runRsdon't do anythingRR[i*s dry run mode(R R=RRRRn(R((RR>s  cCsB|iid}|i|idg|i|idgdS(Ns --dry-runs-n(RRRqRRRvRw(RR((Rttest_conflict_override_opts"scCs|idgddS(Ns-hsXoptions: -h, --help show this help message and exit -n, --dry-run dry run mode (RR2(R((Rttest_conflict_override_help's cCs#|idghddRRR(((RRs  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 tTestHelpcBsYtZdZdZdZdZdZdZdZdZ d Z RS( NcCs|id|_dS(NiP(Rt make_parserR(R((RR>gsc Cstddddddddd td d dd dd ddddtdddddddddg}t|tidRRRRRRRR(((RRfs       tTestMatchAbbrevcBstZdZdZRS(NcCsA|itdhdd<dd<dd<dd<ddS(Ns--fs--fozs--foos--fie(RRt _match_abbrevR (R((Rttest_match_abbrevs *cCsJd}hdd<dd<dd<}|it||fdtddS(Ns--fs--fozs--foos--fies,ambiguous option: --f (--fie, --foo, --foz?)(RR twordmapRR%RtBadOptionError(RRR((Rttest_match_abbrev_errors!(RR RR(((RRs cCsOtit}g}t|D]*}|ido|t||qq~S(NtTest( R*tmodulesRtmodRtdirtnamet startswithR|(RRR((Rt _testclassess cCs:ti}x'tD]}|iti|qW|S(N(tunittestt TestSuitetsuiteRt testclasstaddTestt makeSuite(RR((RRs   cCstitdS(N(RYt run_suiteR(((Rt test_mainst__main__(ii(KR*RRRt cStringIOR-tpprintRRYtoptparseR?RutIndentedHelpFormatterRR<tOptionContainerRFt SUPPRESS_HELPR=R@RRRRRRRt NameErrort ExceptionRR tTestCaseRR:RiRRRRRRRRRR RRR-R6R<R@RCRRRbRoRwR~RRRRRRRRRRRRRRRRRtmain(CRYRRRRRR:RRRoRwRRRRR RRRRRRuRiRRRRRRR~RbRRR<RR6RRRRR*RRR<RR-RRFRRRRCR@RRR-RR@R RRR?R=RRRRR((Rt? sp       a |=6 3*N%:"'6 6 +   U