Ñò
à"Ic           @   sï   d  d k  Z  d  d k Z d  d k Z d  d k Z d  d k l Z d e i f d „  ƒ  YZ d e i f d „  ƒ  YZ d e f d „  ƒ  YZ	 d	 e f d
 „  ƒ  YZ
 d e	 f d „  ƒ  YZ d e
 f d „  ƒ  YZ d „  Z e d j o e ƒ  n d S(   iÿÿÿÿN(   t   test_supportt
   SortedDictc           B   sD   e  Z d  „  Z d „  Z d „  Z d „  Z d „  Z e Z d „  Z RS(   c         C   s   |  i  i ƒ  } | i ƒ  | S(   N(   t   datat   itemst   sort(   t   selft   result(    (    s0   /mit/python/lib/python2.6/test/test_cfgparser.pyR   	   s    
c         C   s   |  i  i ƒ  } | i ƒ  | S(   N(   R   t   keysR   (   R   R   (    (    s0   /mit/python/lib/python2.6/test/test_cfgparser.pyR      s    
c         C   s/   |  i  ƒ  } g  } t D] } | | d q ~ S(   Ni   (   R   t   values(   R   R   t   _[1]t   i(    (    s0   /mit/python/lib/python2.6/test/test_cfgparser.pyR      s    c         C   s   t  |  i ƒ  ƒ S(   N(   t   iterR   (   R   (    (    s0   /mit/python/lib/python2.6/test/test_cfgparser.pyt	   iteritems   s    c         C   s   t  |  i ƒ  ƒ S(   N(   R   R   (   R   (    (    s0   /mit/python/lib/python2.6/test/test_cfgparser.pyt   iterkeys   s    c         C   s   t  |  i ƒ  ƒ S(   N(   R   R   (   R   (    (    s0   /mit/python/lib/python2.6/test/test_cfgparser.pyt
   itervalues   s    (	   t   __name__t
   __module__R   R   R   R   R   t   __iter__R   (    (    (    s0   /mit/python/lib/python2.6/test/test_cfgparser.pyR      s   					t   TestCaseBasec           B   sž   e  Z d d  „ Z d d „ Z d „  Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 d „  Z d	 „  Z d
 „  Z d „  Z d „  Z d „  Z d „  Z d „  Z RS(   c         C   s9   | d  j o |  i ƒ  |  _ n |  i | ƒ |  _ |  i S(   N(   t   Nonet   config_classt   cf(   R   t   defaults(    (    s0   /mit/python/lib/python2.6/test/test_cfgparser.pyt	   newconfig   s    c         C   s/   |  i  | ƒ } t i | ƒ } | i | ƒ | S(   N(   R   t   StringIOt   readfp(   R   t   stringR   R   t   sio(    (    s0   /mit/python/lib/python2.6/test/test_cfgparser.pyt
   fromstring$   s    c      	   C   sy  |  i  d ƒ } | i ƒ  } | i ƒ  |  i } | | d d d d d d d g ƒ | | i d d	 ƒ d
 ƒ | | i d d	 ƒ d
 ƒ | | i d d	 ƒ d
 ƒ | | i d d ƒ d ƒ | | i d d ƒ d ƒ |  i d | i d ƒ j d ƒ |  i | i d d	 ƒ d ƒ |  i | i	 d d	 ƒ d ƒ |  i | i d d	 ƒ d ƒ |  i
 t i | i d d	 ƒ | | i d d	 ƒ d ƒ d  S(   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 Bars   Foo Bars   Internationalized Stuffs	   Long Lines   Section\with$weird%characters[	t   Spacess
   Spacey Bart   foot   bars   key with spacest   values   another with spacess   splat!R   s3   __name__ "option" should not be exposed by the API!s4   remove_option() failed to report existance of options'   remove_option() failed to remove optionsI   remove_option() failed to report non-existance of option that was removeds   No Such Sections7   this line is much, much longer than my editor
likes it.(   R   t   sectionsR   t   assertEqualt   gett   failIft   optionst
   failUnlesst   remove_optiont
   has_optiont   assertRaisest   ConfigParsert   NoSectionError(   R   R   t   Lt   eq(    (    s0   /mit/python/lib/python2.6/test/test_cfgparser.pyt
   test_basic*   s:    	
		
c         C   sË  |  i  ƒ  } | i d ƒ | i d ƒ | i ƒ  } | i ƒ  |  i } | | d d g ƒ | i d d d ƒ | | i d ƒ d g ƒ | | i d d ƒ d d ƒ |  i | i	 d d ƒ ƒ | i d d d ƒ x* d D]" } |  i | i	 d | ƒ d ƒ qÓ W| | i d ƒ d	 g ƒ | | i d ƒ d g ƒ | i
 d d ƒ | | i d ƒ g  ƒ |  i d ƒ } | | i d ƒ d g ƒ | | i d d ƒ d ƒ |  i d d h d d 6ƒ} |  i | i	 d d ƒ ƒ d  S(   Nt   At   at   BR    t   bs@   could not locate option, expecting case-insensitive option namess   A-Bs	   A-B values   a-bs   A-bs   a-Bs9   has_option() returned false for option which should exists,   [MySection]
Option: first line
	second line
t	   MySectiont   optiont   Options   first line
second lines   [section]
nekey=nevalue
R   t   keyt   sectiont   Key(   s   a-bs   A-bs   a-Bs   A-B(   R   t   add_sectionR!   R   R"   t   setR%   R#   R&   R(   R'   R   (   R   R   R,   R-   t   opt(    (    s0   /mit/python/lib/python2.6/test/test_cfgparser.pyt   test_case_sensitivityg   s:    
	 	c         C   sn   |  i  h d d 6ƒ } |  i | i d d ƒ d d ƒ |  i  h d d 6ƒ } |  i | i d d ƒ d d ƒ d  S(   Nt   BarR   t   DEFAULTt   Foos@   could not locate option, expecting case-insensitive option namess<   could not locate option, expecting case-insensitive defaults(   R   R"   R#   (   R   R   (    (    s0   /mit/python/lib/python2.6/test/test_cfgparser.pyt   test_default_case_sensitivityŠ   s    c         C   s€   |  i  ƒ  |  i t i d ƒ |  i t i d ƒ |  i t i d ƒ |  i t i d ƒ |  i t i d ƒ |  i t i d ƒ d  S(   Ns   [Foo]
  extra-spaces: splat
s   [Foo]
  extra-spaces= splat
s   [Foo]
option-without-value
s!   [Foo]
:value-without-option-name
s!   [Foo]
=value-without-option-name
s   No Section!
(   R   t   parse_errorR*   t   ParsingErrort   MissingSectionHeaderError(   R   (    (    s0   /mit/python/lib/python2.6/test/test_cfgparser.pyt   test_parse_errors”   s    
c         C   s,   t  i  | ƒ } |  i | |  i i | ƒ d  S(   N(   R   R)   R   R   (   R   t   exct   srcR   (    (    s0   /mit/python/lib/python2.6/test/test_cfgparser.pyRA   £   s    c         C   s³   |  i  ƒ  } |  i | i ƒ  g  d ƒ |  i | i d ƒ d ƒ |  i t i | i d ƒ |  i t i | i	 d d d ƒ |  i
 t i d d ƒ | i d ƒ |  i
 t i d d ƒ d  S(   Ns0   new ConfigParser should have no defined sectionsR?   s5   new ConfigParser should have no acknowledged sectionsR   R   R    (   R   R"   R!   R$   t   has_sectionR)   R*   R+   R%   R:   t	   get_errorR9   t   NoOptionError(   R   R   (    (    s0   /mit/python/lib/python2.6/test/test_cfgparser.pyt   test_query_errors§   s    c         C   sQ   y |  i  i | | ƒ Wn | j
 o
 } | SX|  i d | i | i f ƒ d  S(   Ns   expected exception type %s.%s(   R   R#   t   failR   R   (   R   RE   R7   R4   t   e(    (    s0   /mit/python/lib/python2.6/test/test_cfgparser.pyRH   µ   s    	c         C   s„   |  i  d ƒ } xn t d d ƒ D]] } |  i | i d d | ƒ ƒ |  i | i d d | ƒ ƒ |  i t | i d d | ƒ q Wd  S(   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 MOREi   i   t   BOOLTESTs   t%ds   f%ds   e%d(   R   t   rangeR&   t
   getbooleanR$   R)   t
   ValueError(   R   R   t   x(    (    s0   /mit/python/lib/python2.6/test/test_cfgparser.pyt   test_boolean¾   s    	 	c         C   s6   |  i  ƒ  } | i d ƒ |  i t i | i d ƒ d  S(   NR?   (   R   R9   R)   R*   t   DuplicateSectionError(   R   R   (    (    s0   /mit/python/lib/python2.6/test/test_cfgparser.pyt   test_weird_errors×   s    c         C   sB   |  i  d ƒ } t i ƒ  } | i | ƒ |  i | i ƒ  d ƒ d  S(   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.

(   R   R   t   writeR"   t   getvalue(   R   R   t   output(    (    s0   /mit/python/lib/python2.6/test/test_cfgparser.pyt
   test_writeÝ   s    		c         C   sÑ   |  i  d ƒ } d t f d „  ƒ  Y} | i d d d ƒ | i d d | d ƒ ƒ | i d d d ƒ | i d d | d ƒ ƒ y t Wn t j
 o n4 X| i d d t d ƒ ƒ | i d d t d ƒ ƒ d  S(   Ns   [sect]
option1=foo
t   mystrc           B   s   e  Z RS(    (   R   R   (    (    (    s0   /mit/python/lib/python2.6/test/test_cfgparser.pyRY   ù   s   t   sectt   option1t   splatt   option2(   R   t   strR:   t   unicodet	   NameError(   R   R   RY   (    (    s0   /mit/python/lib/python2.6/test/test_cfgparser.pyt   test_set_string_typesô   s    c         C   s  t  i d ƒ } |  i ƒ  } | i | d g ƒ } |  i | | g ƒ |  i | i d d ƒ d ƒ |  i ƒ  } | i | ƒ } |  i | | g ƒ |  i | i d d ƒ d ƒ |  i ƒ  } | i d g ƒ } |  i | g  ƒ |  i ƒ  } | i g  ƒ } |  i | g  ƒ d  S(   Ns   cfgparser.1s   nonexistant-files   Foo BarR   t   newbar(   R    t   findfileR   t   readR"   R#   (   R   t   file1R   t   parsed_files(    (    s0   /mit/python/lib/python2.6/test/test_cfgparser.pyt   test_read_returns_file_list  s    c         C   s   |  i  d d h d d 6ƒ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
R   s   %(__name__)st   getname(   R   (   R   (    (    s0   /mit/python/lib/python2.6/test/test_cfgparser.pyt   get_interpolation_config  s    c         C   sO   |  i  d d h d d 6ƒ} t | i d ƒ ƒ } | i ƒ  |  i | | ƒ d  S(   NsY   [section]
name = value
key: |%(name)s| 
getdefault: |%(default)s|
getname: |%(__name__)s|R   s	   <default>t   defaultR7   (   R   t   listR   R   R"   (   R   t   expectedR   R,   (    (    s0   /mit/python/lib/python2.6/test/test_cfgparser.pyt   check_items_config9  s    
N(   R   R   R   R   R   R.   R<   R@   RD   RA   RJ   RH   RR   RT   RX   Ra   Rg   Ri   Rm   (    (    (    s0   /mit/python/lib/python2.6/test/test_cfgparser.pyR      s    	=	#	
											t   ConfigParserTestCasec           B   s5   e  Z e i Z d  „  Z d „  Z d „  Z d „  Z RS(   c         C   s“   |  i  ƒ  } |  i } | | i d d ƒ d ƒ | | i d d ƒ d ƒ | | i d d ƒ d ƒ | | i d d ƒ d ƒ |  i t i d d	 ƒ d  S(
   NR?   Rh   R   s%   something with interpolation (1 step)t   bar9s.   something with lots of interpolation (9 steps)t   bar10s/   something with lots of interpolation (10 steps)t   bar11(   Ri   R"   R#   RH   R*   t   InterpolationDepthError(   R   R   R-   (    (    s0   /mit/python/lib/python2.6/test/test_cfgparser.pyt   test_interpolationI  s    	c         C   sa   |  i  ƒ  } |  i t i d d ƒ } |  i | i d ƒ |  i | i d ƒ |  i | i d ƒ d  S(   Ns   Interpolation Errort   namet	   reference(   Ri   RH   R*   t   InterpolationErrorR"   Ru   R7   R4   (   R   R   RL   (    (    s0   /mit/python/lib/python2.6/test/test_cfgparser.pyt    test_interpolation_missing_valueT  s    c         C   s    |  i  d d d d d g ƒ d  S(   NRj   s	   <default>t
   getdefaults   |<default>|Rh   s	   |section|R6   s   |value|Rt   R    (   s   defaults	   <default>(   Rx   s   |<default>|(   s   getnames	   |section|(   s   keys   |value|(   s   names   value(   Rm   (   R   (    (    s0   /mit/python/lib/python2.6/test/test_cfgparser.pyt
   test_items\  s
    	c         C   s»  |  i  ƒ  } | i d ƒ | i d d d ƒ | i d d d d d d d d d	 d
 d g	 ƒ | i d d h d d 6d d 6d d 6ƒ | i d d d ƒ |  i | i d d d t ƒd ƒ |  i t | i d d ƒ |  i | i d d d t ƒd d d d d d d	 d
 d g	 ƒ |  i t | i d d ƒ |  i | i d d d t ƒh d d 6d d 6d d 6ƒ |  i t | i d d ƒ |  i | i d d d t ƒd ƒ |  i t | i d d d t	 ƒd  S(   Ns
   non-stringt   inti   Rk   i    i   i   i   i   i   s   %(t   dictgn†ðù!	@t   pis   %(list)t   string_with_interpolations   %(list)st   raw(
   R   R9   R:   R"   R#   t   TrueR)   t	   TypeErrorRP   t   False(   R   R   (    (    s0   /mit/python/lib/python2.6/test/test_cfgparser.pyt   test_set_nonstring_typesc  s&    .""(   R   R   R*   R   Rs   Rw   Ry   R‚   (    (    (    s0   /mit/python/lib/python2.6/test/test_cfgparser.pyRn   F  s
   				t   RawConfigParserTestCasec           B   s,   e  Z e i Z d  „  Z d „  Z d „  Z RS(   c         C   s–   |  i  ƒ  } |  i } | | i d d ƒ d ƒ | | i d d ƒ d ƒ | | i d d ƒ d ƒ | | i d d ƒ d	 ƒ | | i d d
 ƒ d ƒ d  S(   NR?   Rh   s   %(__name__)sR   s*   something %(with1)s interpolation (1 step)Ro   s3   something %(with9)s lots of interpolation (9 steps)Rp   s5   something %(with10)s lots of interpolation (10 steps)Rq   s5   something %(with11)s lots of interpolation (11 steps)(   Ri   R"   R#   (   R   R   R-   (    (    s0   /mit/python/lib/python2.6/test/test_cfgparser.pyRs   |  s    	c         C   s    |  i  d d d d d g ƒ d  S(   NRj   s	   <default>Rx   s   |%(default)s|Rh   s   |%(__name__)s|R6   s
   |%(name)s|Rt   R    (   s   defaults	   <default>(   s
   getdefaults   |%(default)s|(   s   getnames   |%(__name__)s|(   s   keys
   |%(name)s|(   s   names   value(   Rm   (   R   (    (    s0   /mit/python/lib/python2.6/test/test_cfgparser.pyRy   ‰  s
    	c         C   sè   |  i  ƒ  } | i d ƒ | i d d d ƒ | i d d d d d d d d d	 d
 g ƒ | i d d h d d 6ƒ |  i | i d d ƒ d ƒ |  i | i d d ƒ d d d d d d d	 d
 g ƒ |  i | i d d ƒ h d d 6ƒ d  S(   Ns
   non-stringRz   i   Rk   i    i   i   i   i   i   R{   gn†ðù!	@R|   (   R   R9   R:   R"   R#   (   R   R   (    (    s0   /mit/python/lib/python2.6/test/test_cfgparser.pyR‚     s    +(   R   R   R*   t   RawConfigParserR   Rs   Ry   R‚   (    (    (    s0   /mit/python/lib/python2.6/test/test_cfgparser.pyRƒ   y  s   			t   SafeConfigParserTestCasec           B   s>   e  Z e i Z d  „  Z d „  Z d „  Z d „  Z d „  Z	 RS(   c         C   sK   |  i  d ƒ } |  i | i d d ƒ d ƒ |  i | i d d ƒ d ƒ d  S(   NsW   [section]
option1=xxx
option2=%(option1)s/xxx
ok=%(option1)s/%%s
not_ok=%(option2)s/%%sR7   t   oks   xxx/%st   not_oks
   xxx/xxx/%s(   R   R"   R#   (   R   R   (    (    s0   /mit/python/lib/python2.6/test/test_cfgparser.pyt   test_safe_interpolationŸ  s    c         C   sŸ   |  i  d ƒ } |  i | i d d ƒ d ƒ |  i t | i d d d ƒ |  i t | i d d d ƒ |  i t | i d d d ƒ |  i | i d d ƒ d ƒ d  S(   Ns   [sect]
option1=foo
RZ   R[   R   s   %foos   foo%s   f%oo(   R   R"   R#   R)   RP   R:   (   R   R   (    (    s0   /mit/python/lib/python2.6/test/test_cfgparser.pyt#   test_set_malformatted_interpolation©  s    c         C   sÁ   |  i  d ƒ } |  i t | i d d d ƒ |  i t | i d d d ƒ |  i t | i d d t ƒ  ƒ |  i t | i d d d ƒ |  i t | i d d d ƒ |  i t | i d d t ƒ  ƒ d  S(   Ns   [sect]
option1=foo
RZ   R[   i   g      ð?R]   (   R   R)   R€   R:   t   object(   R   R   (    (    s0   /mit/python/lib/python2.6/test/test_cfgparser.pyR‚   µ  s    c         C   s&   |  i  ƒ  } |  i t | i d ƒ d  S(   NRj   (   R   R)   RP   R9   (   R   R   (    (    s0   /mit/python/lib/python2.6/test/test_cfgparser.pyt   test_add_section_default_1Á  s    c         C   s&   |  i  ƒ  } |  i t | i d ƒ d  S(   NR>   (   R   R)   RP   R9   (   R   R   (    (    s0   /mit/python/lib/python2.6/test/test_cfgparser.pyt   test_add_section_default_2Å  s    (
   R   R   R*   t   SafeConfigParserR   Rˆ   R‰   R‚   R‹   RŒ   (    (    (    s0   /mit/python/lib/python2.6/test/test_cfgparser.pyR…   œ  s   		
			t   SortedTestCasec           B   s   e  Z d d  „ Z d „  Z RS(   c         C   s"   |  i  d | d t ƒ |  _ |  i S(   NR   t	   dict_type(   R   R   R   (   R   R   (    (    s0   /mit/python/lib/python2.6/test/test_cfgparser.pyR   Ê  s    c         C   sC   |  i  d ƒ t i ƒ  } |  i i | ƒ |  i | i ƒ  d ƒ d  S(   Ns    [b]
o4=1
o3=2
o2=3
o1=4
[a]
k=v
s,   [a]
k = v

[b]
o1 = 4
o2 = 3
o3 = 2
o4 = 1

(   R   R   R   RU   t   assertEqualsRV   (   R   RW   (    (    s0   /mit/python/lib/python2.6/test/test_cfgparser.pyt   test_sortedÎ  s
    N(   R   R   R   R   R‘   (    (    (    s0   /mit/python/lib/python2.6/test/test_cfgparser.pyRŽ   É  s   c           C   s   t  i t t t t ƒ d  S(   N(   R    t   run_unittestRn   Rƒ   R…   RŽ   (    (    (    s0   /mit/python/lib/python2.6/test/test_cfgparser.pyt	   test_mainá  s
    t   __main__(   R*   R   t   unittestt   UserDictt   testR    R   t   TestCaseR   Rn   Rƒ   R…   RŽ   R“   R   (    (    (    s0   /mit/python/lib/python2.6/test/test_cfgparser.pyt   <module>   s   ÿ +3#-	