mò %U²Ic@s¨dkZdkZdkZdklZdeifd„ƒYZdefd„ƒYZdefd„ƒYZdefd „ƒYZ d „Z e d jo e ƒndS( N(s test_supportt TestCaseBasecBsžtZdd„Zdd„Zd„Zd„Zd„Zd„Zd„Z d„Z d „Z d „Z d „Z d „Zd „Zd„Zd„Zd„ZRS(NcCs9|djo|iƒ|_n|i|ƒ|_|iS(N(tdefaultstNonetselft config_classtcf(RR((t0/data/zmath/lib/python2.4/test/test_cfgparser.pyt newconfig s cCs/|i|ƒ}ti|ƒ}|i|ƒ|S(N(RRRRtStringIOtstringtsiotreadfp(RR RRR ((Rt fromstrings c Csy|idƒ}|iƒ}|iƒ|i}||dddddddgƒ||idd ƒd ƒ||idd ƒd ƒ||idd ƒd ƒ||idd ƒd ƒ||idd ƒdƒ|i d|i dƒjdƒ|i |i dd ƒdƒ|i |i dd ƒdƒ|i |i dd ƒdƒ|iti|i dd ƒ||idd ƒdƒdS(NsQ[Foo Bar] foo=bar [Spacey Bar] foo = bar [Commented Bar] foo: bar ; comment [Long Line] foo: this line is much, much longer than my editor likes it. [Section\with$weird%characters[ ] [Internationalized Stuff] foo[bg]: Bulgarian foo=Default foo[en]=English foo[de]=Deutsch [Spaces] key with spaces : value another with spaces = splat! s Commented BarsFoo BarsInternationalized Stuffs Long LinesSection\with$weird%characters[ tSpacess Spacey Bartfootbarskey with spacestvaluesanother with spacesssplat!t__name__s3__name__ "option" should not be exposed by the API!s4remove_option() failed to report existance of options'remove_option() failed to remove optionsIremove_option() failed to report non-existance of option that was removedsNo Such Sections7this line is much, much longer than my editor likes it.(RR RtsectionstLtsortt assertEqualteqtgettfailIftoptionst failUnlesst remove_optiont has_optiont assertRaisest ConfigParsertNoSectionError(RRRR((Rt test_basics,   "  cCsÍ|iƒ}|idƒ|idƒ|iƒ}|iƒ|i}||ddgƒ|i dddƒ||i dƒdgƒ||i ddƒddƒ|i |i ddƒƒ|i dddƒx*dD]"}|i |i d|ƒd ƒqÓW||i dƒd gƒ||i dƒdgƒ|iddƒ||i dƒgƒ|id ƒ}||i dƒdgƒ||i ddƒdƒ|iddhdd<ƒ}|i |i ddƒƒdS(NtAtatBRtbs@could not locate option, expecting case-insensitive option namessA-Bs A-B valuesa-bsA-bsa-Bs9has_option() returned false for option which should exists,[MySection] Option: first line second line t MySectiontoptiontOptionsfirst line second lines[section] nekey=nevalue RtkeytsectiontKey(sa-bsA-bsa-BsA-B(RRRt add_sectionRRRRRtsetRRRRtoptRR (RR-RRR((Rttest_case_sensitivitySs6        cCsr|ihdd<ƒ}|i|iddƒddƒ|ihdd<ƒ}|i|iddƒddƒdS(NRtBartDEFAULTtFoos@could not locate option, expecting case-insensitive option namess<could not locate option, expecting case-insensitive defaults(RRRRR(RR((Rttest_default_case_sensitivityvs cCs€|iƒ|itidƒ|itidƒ|itidƒ|itidƒ|itidƒ|itidƒdS(Ns[Foo] extra-spaces: splat s[Foo] extra-spaces= splat soo] option-without-value s![Foo] :value-without-option-name s![Foo] =value-without-option-name s No Section! (RRt parse_errorRt ParsingErrortMissingSectionHeaderError(R((Rttest_parse_errors€s       cCs,ti|ƒ}|i||ii|ƒdS(N(RtsrcR RRtexcRR (RR8R7R ((RR3scCs³|iƒ}|i|iƒgdƒ|i|idƒdƒ|iti |i dƒ|iti |i dddƒ|i ti ddƒ|i dƒ|i tiddƒdS(Ns0new ConfigParser should have no defined sectionsR1s5new ConfigParser should have no acknowledged sectionsRRR(RRRRRRt has_sectionRRRRR,t get_errorR+t NoOptionError(RR((Rttest_query_errors“s     cCsTy|ii||ƒWn|j o }|SnX|id|i|i fƒdS(Nsexpected exception type %s.%s( RRRR)R&R8tetfailt __module__R(RR8R)R&R=((RR:¡s  cCs„|idƒ}xntddƒD]]}|i|idd|ƒƒ|i|idd|ƒƒ|it |idd|ƒqWdS(Ns{[BOOLTEST] T1=1 T2=TRUE T3=True T4=oN T5=yes F1=0 F2=FALSE F3=False F4=oFF F5=nO E1=2 E2=foo E3=-1 E4=0.1 E5=FALSE AND MOREiitBOOLTESTst%dsf%dse%d( RR RtrangetxRt getbooleanRRt ValueError(RRBR((Rt test_booleanªs cCs6|iƒ}|idƒ|iti|idƒdS(NR1(RRRR+RRtDuplicateSectionError(RR((Rttest_weird_errorsÃs   cCsB|idƒ}tiƒ}|i|ƒ|i|iƒdƒdS(Nsr[Long Line] foo: this line is much, much longer than my editor likes it. [DEFAULT] foo: another very long linesu[DEFAULT] foo = another very long line [Long Line] foo = this line is much, much longer than my editor likes it. (RR RRtoutputtwriteRtgetvalue(RRHR((Rt test_writeÉs   cCsÑ|idƒ}dtfd„ƒY}|idddƒ|idd|dƒƒ|idddƒ|idd|dƒƒytWntj on4X|iddtdƒƒ|iddtdƒƒdS(Ns[sect] option1=foo tmystrcBstZRS(N(RR?(((RRLåstsecttoption1tsplattoption2(RR RtstrRLR,tunicodet NameError(RRRL((Rttest_set_string_typesàscCstidƒ}|iƒ}|i|dgƒ}|i||gƒ|i|i ddƒdƒ|iƒ}|i|ƒ}|i||gƒ|i|i ddƒdƒ|iƒ}|idgƒ}|i|gƒ|iƒ}|igƒ}|i|gƒdS(Ns cfgparser.1snonexistant-filesFoo BarRtnewbar( t test_supporttfindfiletfile1RRRtreadt parsed_filesRR(RRZRXR((Rttest_read_returns_file_listós    cCs|iddhdd<ƒS(Nsê[Foo] bar=something %(with1)s interpolation (1 step) bar9=something %(with9)s lots of interpolation (9 steps) bar10=something %(with10)s lots of interpolation (10 steps) bar11=something %(with11)s lots of interpolation (11 steps) with11=%(with10)s with10=%(with9)s with9=%(with8)s with8=%(With7)s with7=%(WITH6)s with6=%(with5)s With5=%(with4)s WITH4=%(with3)s with3=%(with2)s with2=%(with1)s with1=with [Mutual Recursion] foo=%(bar)s bar=%(foo)s [Interpolation Error] name=%(reference)s Rtgetnames %(__name__)s(RR (R((Rtget_interpolation_config s cCsQ|iddhdd<ƒ}t|idƒƒ}|iƒ|i||ƒdS(NsY[section] name = value key: |%(name)s| getdefault: |%(default)s| getname: |%(__name__)s|Rtdefaults R)( RR RtlisttitemsRRRtexpected(RRaRR((Rtcheck_items_config%s   (RR?RRR R R.R2R6R3R<R:RERGRKRTR[R]Rb(((RRs    = #         tConfigParserTestCasecBs5tZeiZd„Zd„Zd„Zd„ZRS(NcCs“|iƒ}|i}||iddƒdƒ||iddƒdƒ||iddƒdƒ||iddƒdƒ|itidd ƒdS( NR1R\Rs%something with interpolation (1 step)tbar9s.something with lots of interpolation (9 steps)tbar10s/something with lots of interpolation (10 steps)tbar11( RR]RRRRR:RtInterpolationDepthError(RRR((Rttest_interpolation5s  cCsa|iƒ}|itiddƒ}|i|idƒ|i|i dƒ|i|i dƒdS(NsInterpolation Errortnamet reference( RR]RR:RtInterpolationErrorR=RRjR)R&(RR=R((Rt test_interpolation_missing_value@s    cCs |id d d ddgƒdS(NR^s t getdefaults ||R\s |section|R(s|value|RiR(sdefaults (Rms ||(sgetnames |section|(skeys|value|(snamesvalue(RRb(R((Rt test_itemsHsc CsÇ|iƒ}|idƒ|idddƒ|iddddddddd d d g ƒ|idd hd d<d d<dd<ƒ|idddƒ|i|idddtƒdƒ|it |iddƒ|i|idddtƒddddddd d d g ƒ|it |iddƒ|i|idd dtƒhd d<d d<dd<ƒ|it |idd ƒ|i|idddtƒdƒ|it |idddt ƒdS(Ns non-stringtintiR_iiiiii s%(tdicttpif3.1415899999999999s%(list)tstring_with_interpolations%(list)straw( RRRR+R,RRtTrueRt TypeErrorRDtFalse(RR((Rttest_set_nonstring_typesOs&  ..""" (RR?RRRhRlRnRw(((RRc2s    tRawConfigParserTestCasecBs,tZeiZd„Zd„Zd„ZRS(NcCs–|iƒ}|i}||iddƒdƒ||iddƒdƒ||iddƒdƒ||iddƒd ƒ||idd ƒd ƒdS( NR1R\s %(__name__)sRs*something %(with1)s interpolation (1 step)Rds3something %(with9)s lots of interpolation (9 steps)Res5something %(with10)s lots of interpolation (10 steps)Rfs5something %(with11)s lots of interpolation (11 steps)(RR]RRRR(RRR((RRhhs  cCs |id d d ddgƒdS(NR^s Rms |%(default)s|R\s|%(__name__)s|R(s |%(name)s|RiR(sdefaults (s getdefaults |%(default)s|(sgetnames|%(__name__)s|(skeys |%(name)s|(snamesvalue(RRb(R((RRnusc Csì|iƒ}|idƒ|idddƒ|iddddddddd d gƒ|idd hd d <ƒ|i|iddƒdƒ|i|iddƒddddddd d gƒ|i|idd ƒhd d <ƒdS(Ns non-stringRoiR_iiiiii RpRqf3.1415899999999999(RRRR+R,RR(RR((RRw|s  +(RR?RtRawConfigParserRRhRnRw(((RRxes  tSafeConfigParserTestCasecBs#tZeiZd„Zd„ZRS(NcCsK|idƒ}|i|iddƒdƒ|i|iddƒdƒdS(NsW[section] option1=xxx option2=%(option1)s/xxx ok=%(option1)s/%%s not_ok=%(option2)s/%%sR)toksxxx/%stnot_oks xxx/xxx/%s(RR RRR(RR((Rttest_safe_interpolation‹scCsÁ|idƒ}|it|idddƒ|it|idddƒ|it|iddtƒƒ|it|idddƒ|it|idddƒ|it|iddtƒƒdS(Ns[sect] option1=foo RMRNif1.0RP(RR RRRuR,tobject(RR((RRw•s(RR?RtSafeConfigParserRR}Rw(((RRzˆs  cCstitttƒdS(N(RVt run_unittestRcRxRz(((Rt test_main¢s t__main__( RRtunittestttestRVtTestCaseRRcRxRzRR( RVRRRƒRzRxRcRR((Rt?s    ÿ+3#