
    dafYU                       d dl Z d dlZd dlZd dlZd dlZd dlZd dlZd dlmZ d dl	m
Z
  G d de j                        Z G d d      Z G d d	e      Z G d
 deej                        Z G d deej                        Z G d deej                        Z G d de      Z G d dej                        Z G d de      Z G d de      Z G d deej                        Z G d deej                        Z G d de      Z G d deej                        Z G d  d!eej                        Z G d" d#e      Z G d$ d%eej                        Z G d& d'ej                        Z G d( d)e      Z G d* d+eej                        Z  G d, d-eej                        Z! G d. d/      Z"d0 Z# G d1 d2ej                        Z$ G d3 d4ej                        Z% G d5 d6ej                        Z& G d7 d8ej                        Z' G d9 d:ej                        Z( G d; d<eej                        Z) G d= d>ej                        Z* G d? d@ej                        Z+e,dAk(  r ejZ                          yy)B    N)support)	os_helperc                   4    e Zd Zd Zd Zd Zd Zd Zd ZeZ	y)
SortedDictc                 H    t        | j                  j                               S N)sorteddataitemsselfs    1/root/Python-3.12.4/Lib/test/test_configparser.pyr   zSortedDict.items   s    diioo'((    c                 H    t        | j                  j                               S r   )r	   r
   keysr   s    r   r   zSortedDict.keys   s    diinn&''r   c                 N    | j                         D cg c]  }|d   	 c}S c c}w )N   )r   )r   is     r   valueszSortedDict.values   s     "jjl+!+++s   "c                 4    t        | j                               S r   )iterr   r   s    r   	iteritemszSortedDict.iteritems   s    DJJL!!r   c                 4    t        | j                               S r   )r   r   r   s    r   iterkeyszSortedDict.iterkeys   s    DIIK  r   c                 4    t        | j                               S r   )r   r   r   s    r   
itervalueszSortedDict.itervalues   s    DKKM""r   N)
__name__
__module____qualname__r   r   r   r   r   r   __iter__ r   r   r   r      s'    )(,"!# Hr   r   c                   |    e Zd ZdZdZdZdZdZej                  Z
dZej                  Zej                  ZddZddZy)	CfgParserTestCaseClassF)=:);#TNc                    t        || j                  | j                  | j                  | j                  | j
                  | j                  | j                  | j                  | j                  
      } | j                  di |}|S )N)
defaultsallow_no_value
delimiterscomment_prefixesinline_comment_prefixesempty_lines_in_values	dict_typestrictdefault_sectioninterpolationr!   )dictr*   r+   r,   r-   r.   r/   r0   r1   r2   config_class)r   r)   	argumentsinstances       r   	newconfigz CfgParserTestCaseClass.newconfig/   sv    ..!22$($@$@"&"<"<nn;; 00,,
	 %4$$1y1r   c                 J    | j                  |      }|j                  |       |S r   )r7   read_string)r   stringr)   cfs       r   
fromstringz!CfgParserTestCaseClass.fromstring?   s!    ^^H%
v	r   r   )r   r   r   r*   r+   r,   r-   r.   configparser_default_dictr/   r0   DEFAULTSECTr1   _UNSETr2   r7   r<   r!   r   r   r#   r#   $   sN    NJ!( **IF"..O ''M r   r#   c                       e 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d Zd Zd Zd Zd Zd Zd Zd Zd Zd Zy)BasicTestCasec                 <!   g d}| j                   r|j                  d       |j                          ddg}|j                         }|j                          | j                  } |||       |j                  d      }|j                           |||       |D cg c]  }| }}|j                          |j                  | j                         |j                           |||       |d   j                         }t        t        |            } |||       |j                         }t        t        |            }| j	                  t        |      t        |             |D ]  \  }} |||j                           ||j                         || j                             ||j                  dd      d        ||j                  d	d      d
        ||j                  dd      d        ||j                  dd      d        ||j                  dd      d        ||j                  dd      d        ||j                  dd      d        ||j                  dd      d        ||j                  dd      d        ||j                  dd      d       | j                  |j                  dd      d        ||j                  dd      d        ||j!                  dd      d        ||j                  dd      d        ||j                  d d!      d"       | j                   r ||j                  dd#      d         ||j                  ddd$      d        ||j                  ddddi%      d       | j#                  t$        j&                        5  |j                  d&d       d d d        | j#                  t$        j(                        5  |j                  dd'       d d d         ||j                  d&dd$      d        ||j                  dd'd$      d        ||j                  d	dd $      d
        ||j                  d(dd $      d         ||j                  ddd)$      d        ||j                  dd*d)$      d)        ||j                  dd*d+$      d+       | j#                  t$        j(                        5  |j                  dd*       d d d        | j                  |j                  ddd,$      d       | j                  |j                  dd-d,$      d,        ||j                  dd-d.$      d.       | j#                  t$        j(                        5  |j                  dd-       d d d         ||j!                  ddd/$      d        ||j!                  dd0d1$      d1        ||j!                  dd0d/$      d/       | j#                  t$        j(                        5  |j!                  dd0       d d d         ||j!                  d2dd/$      d/       | j                   r6 ||j                  dd#d$      d         ||j                  dd3d$      d        ||d   d   d        ||d	   d   d
       |d   } ||j                  d       | j+                  |j,                  |       | j#                  t.              5  d4|_
        d d d        | j#                  t.              5  d5|_        d d d         ||d   d        ||d   d        ||d   d   d        ||d   d   d        ||d   d   d        ||d   d   d        ||d6   d   d7       | j                   r ||d   d#   d         ||d   j                  dd      d        ||d   j                  dd$      d        ||d   j                  dddi%      d       | j#                  t0              5  |d&   d    d d d        | j#                  t0              5  |d   d'    d d d        | j#                  t0              5  |d&   j                  dd$       d d d         ||d   j                  d'd      d        ||d   j                  d'd$      d        ||d   j                  d'      d         ||d	   j                  dd       d
        ||d	   j                  dd $      d
       | j#                  t0              5  |d(   j                  dd        d d d         ||d   j                  dd)      d        ||d   j                  dd)$      d        ||d   j                  d*d)      d)        ||d   j                  d*d)$      d)        ||d   j                  d*d+      d+        ||d   j                  d*d+$      d+        ||d   j                  d*      d        | j                  |d   j                  dd,      d       | j                  |d   j                  dd,$      d       | j                  |d   j                  d-d,      d,       | j                  |d   j                  d-d,$      d,        ||d   j                  d-d.      d.        ||d   j                  d-d.$      d.        ||d   j                  d-      d         ||d   j!                  dd/      d        ||d   j!                  dd/$      d        ||d   j!                  d0d1      d1        ||d   j!                  d0d1$      d1        ||d   j!                  d0d/      d/        ||d   j!                  d0d/$      d/        ||d   j!                  d0      d        | j                   rr ||d   j                  d#d      d         ||d   j                  d#d$      d         ||d   j                  d3d      d        ||d   j                  d3d$      d       d8|| j                     d9<   d:|| j                     d;<   | j3                  |j5                  d             | j7                  |j9                  dd             | j7                  |j5                  d             | j7                  |j5                  | j                               | j3                  |j;                  dd      d<       | j7                  |j9                  dd      d=       | j7                  |j;                  dd      d>       | j3                  |j9                  dd9             | j7                  |j;                  dd9             | j3                  |j;                  | j                  d9             | j7                  |j9                  dd9             | j7                  |j;                  | j                  d9             | j#                  t$        j&                        5 }|j;                  d?d       d d d        | j	                  j<                  j>                  d@        ||j                  d6d      d7       |d= | j7                  d|v        | j#                  t0              5  |d= d d d        | j#                  t@              5  || j                  = d d d        |d	   d= | j7                  d|d	   v        | j#                  t0              5  |d	   d= d d d        | j3                  d;|d	   v        | j#                  t0              5  |d	   d;= d d d        || j                     d;= | j7                  d;|d	   v        | j#                  t0              5  || j                     d;= d d d        | j#                  t0              5  |d?   d= d d d        y c c}w # 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   
xY w# 1 sw Y   
`xY w# 1 sw Y   	xY w# 1 sw Y   	xY w# 1 sw Y   	xY w# 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   !xY w# 1 sw Y   2xY w# 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   xxY w# 1 sw Y   KxY w# 1 sw Y   xY w# 1 sw Y   y xY w)AN)
Commented BarFoo BarInternationalized Stuff	Long LineSection\with$weird%characters[	Spaces
Spacey BarSpacey Bar From The BeginningTypesThis One Has A ] In ItNoValue)bazqwe)foobar3rK   rE   rQ   bar1rJ   bar2rR   rO   rP   rD   bar4rI   key with spacesvalueanother with spacessplat!rL   int*   42float)\(?z0.44booleanF123strange but acceptablerM   forksspoonsoption-without-valuefallbackvarszNo Such Foo Barzno-such-foozNo Such Spacey Bar   zno-such-int18g        zno-such-floatz0.0Tzno-such-booleanyeszNo Such Typeszno-such-option-without-valuezName is read-onlyzParser is read-onlyrG   7this line is much, much longer than my editor
likes it.1
this_value2
that_valuez4remove_option() failed to report existence of optionz'remove_option() failed to remove optionzIremove_option() failed to report non-existence of option that was removedNo Such Section)rq   )!r*   appendsortsectionsassertEqualr   r1   r	   listlennamer)   getgetintassertAlmostEqualgetfloat
getbooleanassertRaisesr=   NoSectionErrorNoOptionErrorassertIsparserAttributeErrorKeyError
assertTrueremove_sectionassertFalse
has_optionremove_option	exceptionargs
ValueError)	r   r;   EFLeqsectionrx   cms	            r   
basic_testzBasicTestCase.basic_testG   s   
 HHY	_- KKM	
1aHH45	
1a %''W''		%%&	
1a./55747O
1aHHJ47OQQ( 	#MD'tW\\"	#
2;;="T1123 	266)U#V,
266,&/
2661596B
2661595A
266/5)62
266/5)51
266(-.8
266(12H=
299We$b)
266'5!4(r{{7G<dC
266'7#V,
2==),e4
266'5!#;<
266*G4h?rvvi!78$? 	266)UU63V<
266)U%68%@|::; 	-FF$e,	-|99: 	-FF9m,	-
266#UU6;UC
266)]U6;UC
266,65v>
266&6=tD
299Web9126
299Wmb992>
299Wmd9;TB|99: 	.IIg}-	.r{{7G47  +  9:>	@r{{7O47  +  9:=	?
2;;w%;@%H|99: 	2KK1	2
2==)d=;UC
2=="3e=D	
2=="3d=CTJ|99: 	6MM'#45	6
2==)d=CTJrvvi!7%vH$Orvvi!?$  &',. 	2i=(
2lE"F+45
7<<89gnnb)~. 	/.GL	/~. 	32GN	3
75>6"
75>5!
2ou%v.
2ou%u-
2h<)*G4
2h<-.9
2k?5!E	Gr)}34d;
2i=UE*F3
2i=UU3V<
2i=U%8%@x( 	) !%(	)x( 	)yM-(	)x( 	= !%%ee%<	=
2i=]E2E:
2i=]U;UC
2i=]+T2
2lt,f5
2l5v>x( 	6#$((5	6
2g;eR("-
2g;eb126
2g;mR0"5
2g;mb92>
2g;mT2D9
2g;md;TB
2g;m,d3r'{33GSA4Hr'{33G=@  4  BCG	Ir'{33OSI3Or'{33O=@  4  BCF	H
2g;7?
2g;%@%H
2g;0$7
2g;!!)T2E:
2g;!!)d!;UC
2g;!!"3U;UC
2g;!!"3e!D	
2g;!!"3T:DA
2g;!!"3d!CTJ
2g;!!"34d;r)}  !7?Fr)}  !7% H$Or)}  !?GOr)}  !?$ ! &',. 254 .144 . 	))(34x1BCD**845**4+?+?@A((E:N	Py%8=	?)))U;(	) 	i>?)))\BC(()=)=|LMy,?@))$*>*>MN|::; 	7r.6	7**,@A
266+u%E	G wKB'x( 	7	z* 	)4''(	)|U#"\"223x( 	(< '	(<(889x( 	/< .	/t##$\2L)99:x( 	74''(6	7x( 	-$%e,	- 	-} (R	- 	-	- 	-	. 	.	2 	2	6 	6	/ 	/	3 	3 	) 	)	) 	)	= 	=	6 	6r	7 	7	 		) 	)	( 	(	/ 	/	7 	7	- 	-s  	~0~5+6)6:A@5	A@	A@A@*A@7AAAA'AA.AA+(AA82AB AB5~?&)36A@ @A@@A@@A@'@*A@4@7AAAAAAAAAAA(A+AA5A8ABBABBABc                    dj                  | j                  | j                        }| j                  r|dz  }| j	                  |      }| j                  |       | j                  r| j                  t        j                        5  |j                  t        j                  dj                  | j                                     d d d        | j                  t        j                        5  |j                  t        j                  dj                  | j                                     d d d        y |j                  t        j                  dj                  | j                                     |j                  t        j                  dj                  | j                                     y # 1 sw Y   xY w# 1 sw Y   y xY w)Nax  [Foo Bar]
foo{0[0]}bar1
[Spacey Bar]
foo {0[0]} bar2
[Spacey Bar From The Beginning]
  foo {0[0]} bar3
  baz {0[0]} qwe
[Commented Bar]
foo{0[1]} bar4 {1[1]} comment
baz{0[0]}qwe {1[0]}another one
[Long Line]
foo{0[1]} this line is much, much longer than my editor
   likes it.
[Section\with$weird%characters[	]
[Internationalized Stuff]
foo[bg]{0[1]} Bulgarian
foo{0[0]}Default
foo[en]{0[0]}English
foo[de]{0[0]}Deutsch
[Spaces]
key with spaces {0[1]} value
another with spaces {0[0]} splat!
[Types]
int {0[1]} 42
float {0[0]} 0.44
boolean {0[0]} NO
123 {0[1]} strange but acceptable
[This One Has A ] In It]
  forks {0[0]} spoons
z[NoValue]
option-without-value
z                    [Duplicate Options Here]
                    option {0[0]} with a value
                    option {0[1]} with another value
                z                    [And Now For Something]
                    completely different {0[0]} True
                    [And Now For Something]
                    the larch {0[1]} 1
                z                [Duplicate Options Here]
                option {0[0]} with a value
                option {0[1]} with another value
            z                [And Now For Something]
                completely different {0[0]} True
                [And Now For Something]
                the larch {0[1]} 1
            )formatr+   r,   r*   r<   r   r0   r~   r=   DuplicateOptionErrorr9   textwrapdedentDuplicateSectionErrorr   config_stringr;   s      r   
test_basiczBasicTestCase.test_basic'  sn   < F4??D112= 	> )M __]+;;""<#D#DE .x 0 F4??+	 - .. ""<#E#EF .x 0
 F4??+ - .. . NN8?? , t'	) * NN8?? ,
 t') *). .. .s   >F,*>F8,F58Gc                    ddiddiddddddddii d	d
dddddddddddddid
}| j                   r|j                  ddd ii       | j                         }|j                  |       | j	                  |       | j
                  r| j                  t        j                        5  |j                  ddiddid       d d d        | j                  t        j                        5  |j                  dd d!d"i       d d d        y |j                  ddiddid#       |j                  dd d!d"i       y # 1 sw Y   wxY w# 1 sw Y   y xY w)$NrQ   rS   rT   rR   rP   )rQ   rO   rU   rl   	BulgarianDefaultEnglishDeutsch)zfoo[bg]rQ   zfoo[en]zfoo[de]rW   rY   )rV   rX   r[   r^   Fra   )rZ   r]   r_   {   rb   rc   )
rE   rJ   rK   rD   rG   rH   rF   rI   rL   rM   rN   rd   keykey2value2)rm   r   zDuplicate Options Herezwith a valuezwith another value)optionOPTION)r   SECTION)
r*   updater7   	read_dictr   r0   r~   r=   r   r   )r   configr;   s      r   test_basic_from_dictz"BasicTestCase.test_basic_from_dictj  s    v v .
 
  2 ' $$	( $+'/
  -	 'K(
R MM*D 
 ^^
V;;""<#E#EF )) 
 ""<#D#DE ,"0"6/   LL!7+"H-  LL(,2+ # 
 s   'D6'E6D?Ec                 *   | j                         }|j                  d       |j                  d       |j                  d       |j                         }|j                          | j                  } ||g d       |j                  ddd        ||j                  d      dg        ||j                  dd      dd       | j                  t        j                        5  |j                  ddd       d d d        | j                  |j                  dd             | j                  |j                  dd             |j                  ddd	       d
D ]$  }| j                  |j                  d|      d       &  ||j                  d      dg        ||j                  d      dg       |j                  dd        ||j                  d      g        | j                  dj!                  | j"                  d               } ||j                  d      dg        ||j                  dd      d       | j                  dj!                  | j"                  d         ddi      }| j                  |j                  dd             y # 1 sw Y   xY w)NAaB)r   r   r   rW   b@could not locate option, expecting case-insensitive option namesA-B	A-B valuea-bzA-bza-Br   9has_option() returned false for option which should existr   3[MySection]
Option{} first line   
	second line   
r   	MySectionr   Optionfirst line
second line[section]
nekey{}nevalue
r   r)   r   Key)r7   add_sectionrt   rs   ru   setoptionsry   r~   r=   r   r   r   r   r   r<   r   r+   )r   r;   r   r   opts        r   test_case_sensitivityz#BasicTestCase.test_case_sensitivity  s4   ^^
s
s
sKKM	
1o
sC!
2::c?SE"
266#sWM	O|::; 	&FF3W%	& 	c3/0sC01
sE;'/ 	MCOOc3'KM	M 	2::c?UG$
2::c?SE"
c"
2::c?B __ELL"$% 	2::k"XJ/
266+x(*CD __ 006tq7I0J',Wo  7 	i785	& 	&s    JJc           	         | j                         }i |d<   ddi|d<   i |d<   |D cg c]  }| }}|j                          | j                  }| j                  } ||t	        dd| j
                  dg              ||d   j                         dh        ||d   d   dd       | j                  t              5  d|d   d<   d d d        | j                  d|d   v        d|d   d<   d	D ]  }| j                  ||d   v d
         ||d   j                         dh        ||d   j                         dh       |d   d=  ||d   j                         i        | j                  dj                  | j                  d               } ||d   j                         dh        ||d   d   d       | j                  dj                  | j                  d         ddi      }| j                  d|d   v        y c c}w # 1 sw Y   @xY w)Nr   r   rW   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   )r7   rs   ru   assertCountEqualr	   r1   r   r~   r   r   r<   r   r+   )r   r;   r   r   r   elem_eqr   s          r   $test_case_sensitivity_mapping_accessz2BasicTestCase.test_case_sensitivity_mapping_access  s!   ^^3.33$&'W''	''
1fc3 4 4c:;<
2c7<<>C5!
2c73<M	Ox( 	#"BsGCL	# 	r#w'$3/ 	MCOOr#wKM	M 	2c7<<>E7#
2c7<<>C5!sGCL3# __ELL"$% 	2k?!H:.
2k?8$&?@ __ 006tq7I0J',Wo  7 	I./C (	# 	#s   	G;9	H  H
c                    | j                  ddi      }| j                  |j                  | j                  d      dd       | j                  ddi      }| j                  |j                  | j                  d      dd       y )NrQ   BarFoor   z<could not locate option, expecting case-insensitive defaults)r7   ru   ry   r1   r   r;   s     r   test_default_case_sensitivityz+BasicTestCase.test_default_case_sensitivity  sx    ^^UEN+FF4''/N	P ^^UEN+FF4''/J	Lr   c                 l   | j                         }| j                  |t        j                  dj	                  | j
                  d                | j                  |t        j                  dj	                  | j
                  d                | j                  |t        j                  d      }| j                  |j                  d       | j                  s| j                  |t        j                  d      }| j                  |j                  d       t        j                  dd	
      }| j
                  d   dk(  rt        j                  }|f}nt        j                  }|ddf}t        |d      5 }| j                  |||      }d d d        | j                  |j                  |       y y # 1 sw Y   'xY w)Nz[Foo]
{}val-without-opt-name
r   r   No Section!
)<???>r   r   z[Foo]
  wrong-indent
)r   cfgparser.3
configdatasubdirr$   z.  # INI with as many tricky parts as possible
utf-8encoding)r7   parse_errorr=   ParsingErrorr   r+   MissingSectionHeaderErrorru   r   r*   r   findfileopen)r   r;   etrickyerrorexpectedfs          r   test_parse_errorszBasicTestCase.test_parse_errors  s~   ^^\6644:F4??1;M4N	P 	\6644:F4??1;M4N	P R!G!G,.!>?""  \%>%> 9;AQVVZ0%%mLIFq!S($11"9$>>"AMOfw/ 31$$R23QVVX. #3 3s   0F**F3c                     t        |d      r|}nt        j                  |      }| j                  |      5 }|j	                  |       d d d        |j
                  S # 1 sw Y   j
                  S xY w)Nreadline)hasattrioStringIOr~   	read_filer   )r   r;   excsrcsior   s         r   r   zBasicTestCase.parse_error.  s_    3
#C++c"Cs# 	rLL	||	||s   AA0c                    | j                         }| j                  |j                         g d       | j                  |j	                  d      d       | j                  t        j                        5  |j                  d       d d d        | j                  t        j                        5  |j                  ddd       d d d        | j                  |t        j                  dd      }| j                  |j                  d       |j                  d       | j                  |t        j                  dd      }| j                  |j                  d       y # 1 sw Y   xY w# 1 sw Y   xY w)	Nz0new ConfigParser should have no defined sectionsr   z5new ConfigParser should have no acknowledged sectionsrQ   barrW   )rQ   )r   rQ   )r7   ru   rt   r   has_sectionr~   r=   r   r   r   	get_errorr   r   r   r   r;   r   s      r   test_query_errorszBasicTestCase.test_query_errors7  s    ^^K	M.$	% |::; 	JJu	|::; 	*FF5%)	*NN2|::E5I*
uNN2|995%H0	 		* 	*s   2E+E!E!E*c                     	 |j                  ||       | j                  d|j                  d|j                         y # |$ r}|cY d }~S d }~ww xY w)Nzexpected exception type .)ry   failr   r   )r   r;   r   r   r   r   s         r   r   zBasicTestCase.get_errorH  sN    	<FF7F# II)9)9; <  	H	s   A   AAAAc                 \   | j                  dj                  | j                  d               }t        dd      D ]o  }| j	                  |j                  dd|z               | j                  |j                  dd|z               | j                  t        |j
                  dd	|z         q y )
Nz[BOOLTEST]
T1{equals}1
T2{equals}TRUE
T3{equals}True
T4{equals}oN
T5{equals}yes
F1{equals}0
F2{equals}FALSE
F3{equals}False
F4{equals}oFF
F5{equals}nO
E1{equals}2
E2{equals}foo
E3{equals}-1
E4{equals}0.1
E5{equals}FALSE AND MOREr   equalsr      BOOLTESTzt%dzf%dze%d)	r<   r   r+   ranger   r}   r   r~   r   )r   r;   xs      r   test_booleanzBasicTestCase.test_booleanQ  s    __' (.vT__Q5Gv'H!$ q! 	DAOOBMM*eai@AR]]:uqyABj mmZD	Dr   c           	         | j                         }|j                  d       | j                  t        j                        5 }|j                  d       d d d        j
                  }| j                  t        |      d       | j                  |j                  d       | j                  r0| j                  t        j                        5 }|j                  t        j                  dj                  | j                  d               d       d d d        |j
                  }| j                  t        |      d	       | j                  |j                  d
       | j                  t        j                        5 }|j!                  ddddi       d d d        |j
                  }| j                  t        |      d       | j                  |j                  d       y y # 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   gxY w)Nr   zSection 'Foo' already exists)r   NNz                    [Foo]
                    will this be added{equals}True
                    [Bar]
                    what about this{equals}True
                    [Foo]
                    oops{equals}this won't
                r   r   	<foo-bar>sourcezFWhile reading from '<foo-bar>' [line  5]: section 'Foo' already exists)r   r   r   r   valzis really `opt`)r   OPTzIWhile reading from '<dict>': option 'opt' in section 'Bar' already exists)r   r   z<dict>N)r7   r   r~   r=   r   r   ru   strr   r0   r9   r   r   r   r+   r   r   )r   r;   r   r   s       r   test_weird_errorszBasicTestCase.test_weird_errorsj  s   ^^
u|AAB 	"bNN5!	"LLQ!?@!45;;""<#E#EF L"x 0 F$//!"4F5 7 @K  LL ASV &O PQVV%<=""<#D#DE PeU;L%MNOPASV &M NQVV%CD) 	" 	"L LP Ps%   G
AG)8G5G&)G25G>c                    | j                         }t        j                  dj                  | j                  d               }| j
                  r:| j                  t        j                        5  |j                  |       d d d        n|j                  |       | j                  |j                  dd      d       y # 1 sw Y   ,xY w)Nz_            [Foo]
            x{equals}1
            y{equals}2
            y{equals}3
        r   r   r   r   rm   )r7   r   r   r   r+   r0   r~   r=   r   r9   ru   ry   )r   r;   inis      r   %test_get_after_duplicate_option_errorz3BasicTestCase.test_get_after_duplicate_option_error  s    ^^oo 
 F$//!,F-/ ;;""<#D#DE $s#$ $ NN3s+S1	$ $s   .B==Cc                    dj                  | j                  | j                  d   | j                        }| j                  r|dz  }| j                  |      }dD ]  }t        j                         }|j                  ||       | j                  d   }|rdj                  |      }dj                  || j                  	      }| j                  r|d
z  }| j                  |j                         |        y )Na8  [Long Line]
foo{0[0]} this line is much, much longer than my editor
   likes it.
[{default_section}]
foo{0[1]} another very
 long line
[Long Line - With Comments!]
test {0[1]} we        {comment} can
            also      {comment} place
            comments  {comment} in
            multiline {comment} values
r   )commentr1   z![Valueless]
option-without-value
)TF)space_around_delimitersz {} z[{default_section}]
foo{equals}another very
	long line

[Long Line]
foo{equals}this line is much, much longer than my editor
	likes it.

[Long Line - With Comments!]
test{equals}we
	also
	comments
	multiline

)r   r1   z"[Valueless]
option-without-value

)r   r+   r,   r1   r*   r<   r   r   writeru   getvalue)r   r   r;   r	  output	delimiterexpect_strings          r   
test_writezBasicTestCase.test_write  s    1F1Fq1I(,(<(<  > 	 %M
 __]+'4 	?#[[]FHHV5LHM*I&"MM)4	 V9,0,@,@  B " ""
 V__.>;	?r   c                 z   | j                  dj                  | j                  d               } G d dt              }|j	                  ddd       |j	                  dd |d             |j	                  dd	d       |j	                  dd	 |d             |j	                  ddd       |j	                  dd	d       y )
N[sect]
option1{eq}foo
r   r   c                       e Zd Zy)2BasicTestCase.test_set_string_types.<locals>.mystrN)r   r   r   r!   r   r   mystrr    s    r   r  sectoption1splatoption2)r<   r   r+   r  r   )r   r;   r  s      r   test_set_string_typesz#BasicTestCase.test_set_string_types  s    __ 006$//!:L0MO	C 	
vy'*
vy%.1
vy'*
vy%.1
vy'*
vy'*r   c                 d   | j                   d   dk7  r| j                  d       t        j                  dd      }| j	                         }|j                  |dgd	      }| j                  ||g       | j                  |j                  d
d      d       | j	                         }|j                  |d	      }| j                  ||g       | j                  |j                  d
d      d       | j	                         }|j                  t        j                  |      d	      }| j                  ||g       | j                  |j                  d
d      d       | j	                         }|j                  t        j                  |      |gd	      }| j                  |||g       | j                  |j                  d
d      d       | j	                         }|j                  dgd	      }| j                  |g        | j	                         }|j                  g d	      }| j                  |g        y )Nr   r$   incompatible formatcfgparser.1r   r   nonexistent-filer   r   rE   rQ   newbar)
r+   skipTestr   r   r7   readru   ry   r   FakePath)r   file1r;   parsed_filess       r   test_read_returns_file_listz)BasicTestCase.test_read_returns_file_list  s   ??1$MM/0  |D^^ww'9:WwMw/	518<^^wwuww7w/	518<^^wwy11%87wKw/	518<^^ww	 2 25 95AGwTu~6	518<^^ww 23gwFr*^^wwrGw4r*r   c                    | j                   d   dk7  r| j                  d       t        j                  dd      j	                         }| j                         }|j                  |d      }| j                  ||g       | j                         }|j                  d	d      }| j                  |g        | j                         }|j                  |d	gd      }| j                  ||g       y )
Nr   r$   r  r  r   r   r   r   s   nonexistent-file)r+   r   r   r   encoder7   r!  ru   )r   file1_bytestringr;   r$  s       r   0test_read_returns_file_list_with_bytestring_pathz>BasicTestCase.test_read_returns_file_list_with_bytestring_path  s    ??1$MM/0"++M,OVVX^^ww/'wB(8'9:^^ww2WwEr*^^ww 02EFQXwY(8'9:r   c                 ^    | j                  dj                  | j                  d               S )Nah  [Foo]
bar{equals}something %(with1)s interpolation (1 step)
bar9{equals}something %(with9)s lots of interpolation (9 steps)
bar10{equals}something %(with10)s lots of interpolation (10 steps)
bar11{equals}something %(with11)s lots of interpolation (11 steps)
with11{equals}%(with10)s
with10{equals}%(with9)s
with9{equals}%(with8)s
with8{equals}%(With7)s
with7{equals}%(WITH6)s
with6{equals}%(with5)s
With5{equals}%(with4)s
WITH4{equals}%(with3)s
with3{equals}%(with2)s
with2{equals}%(with1)s
with1{equals}with

[Mutual Recursion]
foo{equals}%(bar)s
bar{equals}%(foo)s

[Interpolation Error]
name{equals}%(reference)s
r   r   )r<   r   r+   r   s    r   get_interpolation_configz&BasicTestCase.get_interpolation_config  s1    *. +1&8J&*K1M 	Mr   c                 j   | j                  dj                  | j                        ddi      }t        |j	                  dddi            }|j                          | j                  ||       | j                  t        j                        5  |j	                  d       d d d        y # 1 sw Y   y xY w)	Nz
            [section]
            name {0[0]} %(value)s
            key{0[1]} |%(name)s|
            getdefault{0[1]} |%(default)s|
        default	<default>r   r   rW   rg   zno such section)
r<   r   r+   rv   r   rs   ru   r~   r=   r   )r   r   r;   r   s       r   check_items_configz BasicTestCase.check_items_config*  s    __ 
 F4??#y+.F  H )7G*<=>	H%|::; 	(HH&'	( 	( 	(s   B))B2c                    | j                  dj                  | j                        ddi      }| j                  |j	                         d   d       | j                  |j	                         d   d       | j                  |j	                         d   d       | j                  t              5  |j	                          d d d        y # 1 sw Y   y xY w)	N
            [section1]
            name1 {0[0]} value1
            [section2]
            name2 {0[0]} value2
            [section3]
            name3 {0[0]} value3
        r-  r.  r   r   section1section2section3)r<   r   r+   ru   popitemr~   r   r   s     r   test_popitemzBasicTestCase.test_popitem7  s    __  F4??#y+.F  H 	a*5a*5a*5x( 	JJL	 	 	s   -CCc                 "   | j                  ddi      }| j                  |j                  | j                  d      dd       ddd|d<   | j                  |j	                         dg       | j                  t        |d   j                               h d	       |j                          | j                  t        |j	                               t                      | j                  t        || j                     j                               dh       y )
NrQ   r   r   r   value1r   )r  r  zing>   rQ   r  r  )r7   ru   ry   r1   rt   r   r   clearr   s     r   
test_clearzBasicTestCase.test_clearF  s    ^^UEN+FF4''/N	P "*h?6
1RZ__./1NO

R[[]+SU3R 4 45::<=wGr   c                 :   | j                  dj                  | j                        ddi      }| j                  t	        |d   j                               ddh       | j                  t	        |d   j                               d	dh       | j                  t	        |d
   j                               ddh       | j                  |d   d   d       | j                  |d   d	   d       | j                  |d
   d   d       | j                  |j                         g d       ddi|d<   | j                  t	        |d   j                               ddh       | j                  |d   d   d       | j                  d	|d          | j                  |j                         g d       i |d
<   | j                  t	        |d
   j                               dh       | j                  d|d
          | j                  |j                         g d       || j                     || j                  <   | j                  t	        || j                     j                               t	                      i || j                  <   | j                  t	        || j                     j                               t	                      | j                  t	        |d   j                               dh       | j                  t	        |d   j                               dh       | j                  t	        |d
   j                               t	                      | j                  |j                         g d       |d   |d<   | j                  t	        |d   j                               dh       y )Nr1  nameDvalueDr   r2  name1namedr3  name2r4  name3r8  r   value3)r2  r3  r4  name22value22)
r<   r   r+   ru   r   r   rt   assertNotInr1   assertNotEqualr   s     r   test_setitemzBasicTestCase.test_setitemR  s   __  F4??#w.A  C 	R
^0023gw5GHR
^0023gw5GHR
^0023gw5GHJ0(;J0(;J0(;(LM"I.:R
^0023h5HIJ19="Z.1(LM:R
^0023gY?"Z.1(LM#%d&:&:#;4 C4#7#7 8 = = ?@#%H#%4 R 4 45::<=suER
^0023gY?R
^0023hZ@R
^0023SU;(LMJ:R
^0023hZ@r   c                    | j                   r| j                  d       t        j                  dj	                  | j
                  d               }| j                         }| j                  t        j                        5  |j                  |       d d d        | j                  |j                  dd      d       | j                  |d   d   d       y # 1 sw Y   DxY w)Nz2if no_value is allowed, ParsingError is not raisedzC            [DEFAULT]
            test {0} test
            invalidr   DEFAULTtest)r*   r   r   r   r   r+   r7   r~   r=   r   r9   ru   ry   )r   invalidr;   s      r   test_invalid_multiline_valuez*BasicTestCase.test_invalid_multiline_valuex  s    MMNO// # vdooa01

 ^^|889 	$NN7#	$	62F;Iv.7	$ 	$s   >CCN)r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r  r  r  r%  r)  r+  r/  r6  r;  rH  rM  r!   r   r   rB   rB   E   s    [-@A*FJX'9T&0PL/81"<D2E>24?l++B;$M6(
H$AL8r   rB   c                   (    e Zd Zej                  ZdZy)StrictTestCaseTN)r   r   r   r=   RawConfigParserr4   r0   r!   r   r   rO  rO    s    //LFr   rO  c                   T    e Zd Zej                  Zd Zd Zd Zd Z	d Z
d Zd Zd Zy	)
ConfigParserTestCasec                    | j                         }| j                  } ||j                  dd      d        ||j                  dd      d        ||j                  dd      d       | j                  |t        j
                  dd      }| j                  t        j                  k(  r| j                  |j                  d	       y t        | j                  t        j                        r| j                  |j                  d	       y y )
Nr   r   z%something with interpolation (1 step)bar9z.something with lots of interpolation (9 steps)bar10z/something with lots of interpolation (10 steps)bar11)rV  r   5something %(with11)s lots of interpolation (11 steps))r+  ru   ry   r   r=   InterpolationDepthErrorr2   r@   r   
isinstanceLegacyInterpolation)r   r;   r   r   s       r   test_interpolationz'ConfigParserTestCase.test_interpolation  s    **,
266%!HI
266% ;	=
266%!<	>NN2|CCUGT!4!44QVV &I J**L,L,LMQVV &I J Nr   c                    | j                         }| j                  |t        j                  dd      }| j	                  |j
                  d       | j	                  |j                  d       | j	                  |j                  d       | j                  t        j                  k(  r| j	                  |j                  d       y t        | j                  t        j                        r| j	                  |j                  d       y y )NInterpolation Errorrx   	reference)rx   r]  z%(reference)sr^  )r+  r   r=   InterpolationMissingOptionErrorru   r^  r   r   r2   r@   r   rY  rZ  r   s      r    test_interpolation_missing_valuez5ConfigParserTestCase.test_interpolation_missing_value  s    **,NN2|KK0&:k2$9:6*!4!44QVV &B C**L,L,LMQVV &B C Nr   c                 *    | j                  g d       y )N)r-  r.  )
getdefaultz|<default>|)r   z|value|)rx   rW   r/  r   s    r   
test_itemszConfigParserTestCase.test_items  s     !4 	5r   c                    | j                  dj                  | j                  d               }| j                  |j	                  dd      d       | j
                  t        j                  k(  r#| j                  |j	                  dd      d       y t        | j
                  t        j                        r1| j                  t              5  |j	                  dd       d d d        y y # 1 sw Y   y xY w)	Nzc[section]
option1{eq}xxx
option2{eq}%(option1)s/xxx
ok{eq}%(option1)s/%%s
not_ok{eq}%(option2)s/%%sr   r  r   okzxxx/%snot_okz
xxx/xxx/%s)r<   r   r+   ru   ry   r2   r=   r@   rY  rZ  r~   	TypeErrorr   s     r   test_safe_interpolationz,ConfigParserTestCase.test_safe_interpolation  s    __ 9 :@$(OOA$6 :@ :8	9 		40(;!4!44RVVIx8,G**L,L,LM""9- ,y(+, , N, ,s   
C''C0c                 $   | j                  dj                  | j                  d               }| j                  |j	                  dd      d       | j                  t        |j                  ddd       | j                  t        |j                  ddd       | j                  t        |j                  ddd	       | j                  |j	                  dd      d       |j                  dd
d       | j                  |j	                  dd
      d       y )Nr  r   r  r  r  rQ   %foofoo%f%oor  foo%%barzfoo%bar)r<   r   r+   ru   ry   r~   r   r   r   s     r   #test_set_malformatted_interpolationz8ConfigParserTestCase.test_set_malformatted_interpolation  s    __ 006$//!:L0MO 		2E:*bfffiH*bfffiH*bfffiH	2E: 	vy*-	2I>r   c                    | j                  dj                  | j                  d               }| j                  t        |j
                  ddd       | j                  t        |j
                  ddd       | j                  t        |j
                  ddt                      | j                  t        |j
                  ddd       | j                  t        |j
                  ddd       | j                  t        |j
                  ddt                      | j                  t        |j
                  dd	d
       | j                  t        |j                  d	       y )Nr  r   r  r  r  r   g      ?r  r   zinvalid opt name!)r<   r   r+   r~   ri  r   objectr   r   s     r   test_set_nonstring_typesz-ConfigParserTestCase.test_set_nonstring_types  s    __ 006$//!:L0MO 	)RVVVYB)RVVVYD)RVVVYI)RVVVYB)RVVVYD)RVVVYI)RVVVS:MN)R^^S9r   c                 z    | j                         }| j                  t        |j                  | j                         y r   )r7   r~   r   r   r1   r   s     r   test_add_section_defaultz-ConfigParserTestCase.test_add_section_default  s*    ^^*bnnd6J6JKr   c                    | j                  ddi      }| j                  || j                     d   d       | j                  || j                     j	                  d      d       | j                  ddi      }| j                  || j                     d   d	       | j                  || j                     j	                  d      d       y
)zbpo-23835 fix for ConfigParserr   333333@r   rm   z2.4r   @r   z5.2N)r7   ru   r1   r{   r|   r   s     r   test_defaults_keywordz*ConfigParserTestCase.test_defaults_keyword  s    ^^aX^.D001#6>r$"6"67@@EsK^^c3Z^0D001#6>r$"6"67@@EsKr   N)r   r   r   r=   ConfigParserr4   r[  r`  re  rj  rp  rs  ru  ry  r!   r   r   rR  rR    s9    ,,LJ C5,? :LLr   rR  c                       e Zd Zej                  ZdZ ej                  d      j                         Z
d Zd Zd Zd Zy)#ConfigParserTestCaseNoInterpolationNz
        [numbers]
        one = 1
        two = %(one)s * 2
        three = ${common:one} * 3

        [hexen]
        sixteen = ${numbers:two} * 8
    c                     | j                  |d   d   d       | j                  |d   d   d       | j                  |d   d   d       | j                  |d   d	   d
       y )Nnumbersonerm   twoz%(one)s * 2threez${common:one} * 3hexensixteenz${numbers:two} * 8)ru   r   s     r   assertMatchesIniz4ConfigParserTestCaseNoInterpolation.assertMatchesIni  sh    Iu-s3Iu-}=Iw/1DEGY/1EFr   c                 \    | j                  | j                        }| j                  |       y r   )r<   r  r  r   s     r   test_no_interpolationz9ConfigParserTestCaseNoInterpolation.test_no_interpolation  s"    __TXX&b!r   c                 d    | j                         }| j                  |j                  d             y N )r7   assertIsNoner9   r   s     r   test_empty_casez3ConfigParserTestCaseNoInterpolation.test_empty_case  s%    ^^"..,-r   c                      G d dt         j                        } |       }|j                  | j                         | j	                  |       y )Nc                       e Zd ZdZy)bConfigParserTestCaseNoInterpolation.test_none_as_default_interpolation.<locals>.CustomConfigParserN)r   r   r   _DEFAULT_INTERPOLATIONr!   r   r   CustomConfigParserr    s    %)"r   r  )r=   rz  r9   r  r  )r   r  r;   s      r   "test_none_as_default_interpolationzFConfigParserTestCaseNoInterpolation.test_none_as_default_interpolation
  s<    	*!:!: 	*  !
txx b!r   )r   r   r   r=   rz  r4   r2   r   r   stripr  r  r  r  r  r!   r   r   r|  r|    sH    ,,LM
(//  	 
 G"."r   r|  c                       e Zd Zej                  Z ej                         5   ej                  de	        ej                         Zddd       d Zy# 1 sw Y   d ZyxY w)'ConfigParserTestCaseLegacyInterpolationignoreNc                 L   | j                  dj                  | j                  d               }| j                  |j	                  dd      d       |j                  ddd       | j                  |j	                  dd      d       |j                  ddd       | j                  |j	                  dd      d       |j                  ddd	       | j                  |j	                  dd      d	       |j                  dd
d       | j                  |j	                  dd
      d       y )Nr  r   r  r  r  rQ   rl  rm  rn  r  ro  )r<   r   r+   ru   ry   r   r   s     r   rp  zKConfigParserTestCaseLegacyInterpolation.test_set_malformatted_interpolation  s    __ 006$//!:L0MO 		2E:
vy&)	2F;
vy&)	2F;
vy&)	2F; 	vy*-	2J?r   )r   r   r   r=   rz  r4   warningscatch_warningssimplefilterDeprecationWarningrZ  r2   rp  r!   r   r   r  r    sZ    ,,L	 	 	 	" ;h(:;888:;@	;@s   %AAr  c                       e Zd Zd Zy),ConfigParserTestCaseInvalidInterpolationTypec                    t         j                  ddfD ]Q  }| j                  |      5  | j                  t              5  t        j
                  |       d d d        d d d        S y # 1 sw Y   xY w# 1 sw Y   jxY w)Nr[   za string)rW   r2   )r=   ExtendedInterpolationsubTestr~   ri  rz  )r   rW   s     r   *test_error_on_wrong_type_for_interpolationzWConfigParserTestCaseInvalidInterpolationType.test_error_on_wrong_type_for_interpolation,  s    "882
K 	CEE* C&&y1 C --EBCC C	CC CC Cs"   A5A)A5)A2.A55A>	N)r   r   r   r  r!   r   r   r  r  +  s    Cr   r  c                       e Zd ZdZdZdZy))ConfigParserTestCaseNonStandardDelimitersz:=$//"Nr   r   r   r+   r,   r-   r!   r   r   r  r  3      J")r   r  c                       e Zd ZdZy)-ConfigParserTestCaseNonStandardDefaultSectiongeneralN)r   r   r   r1   r!   r   r   r  r  9  s    Or   r  c                   Z    e Zd Zej                  Zdj                  dd      Zd Zd Z	d Z
y)MultilineValuesTestCasezSI'm having spam spam spam spam spam spam spam beaked beans spam spam spam and spam! 	
c                    | j                         }t        d      D ]`  }dj                  |      }|j                  |       t        d      D ].  }|j	                  |dj                  |      | j
                         0 b t        t        j                  dd      5 }|j                  |       d d d        y # 1 sw Y   y xY w)Nd   z	section{}
   zlovely_spam{}wr   r   )
r7   r   r   r   r   wonderful_spamr   r   TESTFNr
  )r   r;   r   sjr   s         r   setUpzMultilineValuesTestCase.setUpC  s    ^^s 	JA""1%ANN12Y Jq/003T5H5HIJ	J
 )""C': 	aHHQK	 	 	s   B66B?c                 J    t        j                  t        j                         y r   )osunlinkr   r  r   s    r   tearDownz MultilineValuesTestCase.tearDownM  s    
		)""#r   c                    | j                         }t        t        j                  d      5 }|j	                  |       d d d        | j                  |j                  dd      | j                  j                  dd             y # 1 sw Y   FxY w)Nr   r   section8lovely_spam4r  
)	r7   r   r   r  r   ru   ry   r  replace)r   cf_from_filer   s      r    test_dominating_multiline_valuesz8MultilineValuesTestCase.test_dominating_multiline_valuesP  sy     ~~')""W5 	&""1%	&))*nE,,44VTB	D	& 	&s   BBN)r   r   r   r=   rz  r4   r  r  r  r  r  r!   r   r   r  r  =  s3    ,,L,-4WS&-A $Dr   r  c                   <    e Zd Zej                  Zd Zd Zd Zd Z	y)RawConfigParserTestCasec                    | j                         }| j                  } ||j                  dd      d        ||j                  dd      d        ||j                  dd      d        ||j                  dd      d	       y )
Nr   r   z*something %(with1)s interpolation (1 step)rT  z3something %(with9)s lots of interpolation (9 steps)rU  z5something %(with10)s lots of interpolation (10 steps)rV  rW  )r+  ru   ry   r   r;   r   s      r   r[  z*RawConfigParserTestCase.test_interpolation]  s~    **,
266%7	9
266% @	B
266%!B	D
266%!B	Dr   c                 *    | j                  g d       y )N)rb  )rc  z|%(default)s|)r   z
|%(name)s|)rx   z	%(value)srd  r   s    r   re  z"RawConfigParserTestCase.test_itemsi  s     !8 	9r   c                    | j                         }|j                  d       |j                  ddd       |j                  ddg d       |j                  ddddi       | j                  |j	                  dd      d       | j                  |j	                  dd      g d       | j                  |j	                  dd      ddi       |j                  d	       |j                  d	d
d       | j                  |j	                  d	d
      d       |j
                  t        j                  u r>d |_        |j                  ddd       | j                  |j	                  dd      d       y y )Nz
non-stringrZ   r   rv   )r   r   r         r         r3   pign!	@r   zthis is sickTc                     | S r   r!   )r   s    r   <lambda>zBRawConfigParserTestCase.test_set_nonstring_types.<locals>.<lambda>  s    q r   )	r7   r   r   ru   ry   _dictr=   r>   optionxformr   s     r   rs  z0RawConfigParserTestCase.test_set_nonstring_typeso  s)   ^^
|$
|UA&
|V%>?
|VdG_5e4a8f52	4f5gG
s
sND)^4d;88|111 )BNFF<A&RVVL!4a8 2r   c                 :   | j                  t              5 }| j                  ddi       ddd       j                  }| j	                  t        |      d       | j                  ddi      }| j                  || j                     d   d       y# 1 sw Y   gxY w)	z-bpo-23835 legacy behavior for RawConfigParserr   rw  r   Nz%'int' object has no attribute 'lower'r   rx  r   )r~   r   r7   r   ru   r  r{   r1   )r   ctxerrr;   s       r   ry  z-RawConfigParserTestCase.test_defaults_keyword  s    ~. 	.#NNQHN-	.mmS#JK^^c3Z^0r$"6"67<cB	. 	.s   BBN)
r   r   r   r=   rP  r4   r[  re  rs  ry  r!   r   r   r  r  Z  s#    //L
D99(Cr   r  c                       e Zd ZdZdZdZy),RawConfigParserTestCaseNonStandardDelimitersr  r  Nr  r!   r   r   r  r    r  r   r  c                   6    e Zd Zej                  ZdZdZdZd Z	y)RawConfigParserTestSambaConf)r'   r&   z----)r  Fc                    t        j                  dd      }| j                         }|j                  |dgd      }| j	                  ||g       g d}| j	                  |j                         |       | j	                  |j                  dd	      d
       | j	                  |j                  dd      d       | j	                  |j                  dd      d       | j	                  |j                  dd      d       y )Nzcfgparser.2r   r   r  r   r   )globalhomesprinterszprint$zpdf-generatortmpAgustinr  	workgroupMDKGROUPzmax log size2   zhosts allowz127.r  zecho commandzcat %s; rm %s)r   r   r7   r!  ru   rt   ry   rz   )r   smbconfr;   r$  rt   s        r   test_readingz)RawConfigParserTestSambaConf.test_reading  s    ""=F^^ww);<wwOy1A1+6
C8^<bA-8&A~6Hr   N)
r   r   r   r=   rP  r4   r,   r-   r.   r  r!   r   r   r  r    s%    //L)%!Ir   r  c                   z    e Zd Zej                  Z ej                         ZdZdZ	ddZ
d Zd Zd Zd Zd	 Zd
 Zy))ConfigParserTestCaseExtendedInterpolationcommonTNc                 \    | j                  |      }|r||_        |j                  |       |S r   )r7   r  r9   )r   r:   r)   r  r;   s        r   r<   z4ConfigParserTestCaseExtendedInterpolation.fromstring  s+    ^^H%(BN
v	r   c                 ~   | j                  t        j                  d      j                               }| j                  } ||d   d   d        ||d   d   d        ||d   d   d        ||d   d   d        ||d   d   d	        ||d   d
   d        ||d   d   d        ||d   d   d        ||d   d   d        ||d   d   d        ||d   d   d        ||d   d   d        ||d   d   d        ||d   d   d        ||d   d   d        ||d   d
   d        ||d   d   d       y )Na  
            [common]
            favourite Beatle = Paul
            favourite color = green

            [tom]
            favourite band = ${favourite color} day
            favourite pope = John ${favourite Beatle} II
            sequel = ${favourite pope}I

            [ambv]
            favourite Beatle = George
            son of Edward VII = ${favourite Beatle} V
            son of George V = ${son of Edward VII}I

            [stanley]
            favourite Beatle = ${ambv:favourite Beatle}
            favourite pope = ${tom:favourite pope}
            favourite color = black
            favourite state of mind = paranoid
            favourite movie = soylent ${common:favourite color}
            favourite song = ${favourite color} sabbath - ${favourite state of mind}
        r  zfavourite BeatlePaulzfavourite colorgreentomzfavourite bandz	green dayzfavourite popezJohn Paul IIsequelzJohn Paul IIIambvGeorgezson of Edward VIIzGeorge Vzson of George Vz	George VIstanleyblackzfavourite state of mindparanoidzfavourite moviezsoylent greenzfavourite songzblack sabbath - paranoid)r<   r   r   r  ru   r  s      r   test_extended_interpolationzEConfigParserTestCaseExtendedInterpolation.test_extended_interpolation  s   __X__ . , UW-0 
2h<*+V4
2h<)*G4
2e9'(&1
2e9&'1
2e9%&4
2e9%&7
2e9X0
2f:()84
2f:'('2
2f:)*J7
2f:'(+6
2i=+,h7
2i=*+W5
2i=23Z@
2i=*+_=
2i=)*N;
2i=)*%	'r   c                 X   | j                  t        j                  d      j                               }| j	                  t
        j                        5  |d   d    d d d        | j	                  t
        j                        5  |d   d    d d d        y # 1 sw Y   :xY w# 1 sw Y   y xY w)Nz
            [one for you]
            ping = ${one for me:pong}

            [one for me]
            pong = ${one for you:ping}

            [selfish]
            me = ${me}
        zone for youpingselfishme)r<   r   r   r  r~   r=   rX  r   s     r   test_endless_loopz;ConfigParserTestCaseExtendedInterpolation.test_endless_loop  s    __X__ 	. 	 UW	 |CCD 	&}f%	&|CCD 	 yM$	  	 	& 	&	  	 s   	B	B B B)c                    | j                  d      }| j                  |d   d   d       | j                  |d   d   d       | j                  |d   d   d       t        j                  }| j	                  |      5 }|d   d	    d d d        | j                  j
                  j                  d
       | j                  |j
                  j                  d   d       y # 1 sw Y   YxY w)Nz
            [dollars]
            $var = $$value
            $var2 = ${$var}
            ${sick} = cannot interpolate me

            [interpolated]
            $other = ${dollars:$var}
            $trying = ${dollars:${sick}}
        dollarsz$varz$valueinterpolatedz$otherz${sick}zcannot interpolate mez$tryingzdollars:${sickr  z${dollars:${sick}})r<   ru   r=   r_  r~   r   r^  r   )r   r;   exception_classr   s       r   test_strange_optionsz>ConfigParserTestCaseExtendedInterpolation.test_strange_options  s    __ 	 	 	Iv.9N+H5x@Iy13JK&FF/ 	*2~y)	*//1AB**1-/CD	* 	*s   ;	CC%c                 8   t        j                  d      j                         }| j                  |      }| j                  } ||d   d   d        ||d   d   d        ||d   d   d        ||d   d   d	        ||d
   d   d        ||d
   d   d       y )Naj  
            [common]
            optionlower = value
            OptionUpper = Value

            [Common]
            optionlower = a better ${common:optionlower}
            OptionUpper = A Better ${common:OptionUpper}

            [random]
            foolower = ${common:optionlower} redefined
            FooUpper = ${Common:OptionUpper} Redefined
        r  optionlowerrW   OptionUpperValueCommona better valueA Better Valuerandomfoolowervalue redefinedFooUpperA Better Value Redefined)r   r   r  r<   ru   r   r  r;   r   s       r   test_case_sensitivity_basiczEConfigParserTestCaseExtendedInterpolation.test_case_sensitivity_basic  s    oo   UW 	 __S!
2h<&0
2h<&0
2h<&(89
2h<&(89
2h<
#%67
2h<
#%?@r   c                    t        j                  d      j                         }| j                  t        j
                        5  | j                  |      }d d d        | j                  |d       }| j                  } ||d   d   d        ||d   d   d        ||d	   d   d
        ||d	   d   d        ||d   d   d        ||d   d   d       y # 1 sw Y   xY w)Na8  
            [common]
            option = value
            Option = Value

            [Common]
            option = a better ${common:option}
            Option = A Better ${common:Option}

            [random]
            foo = ${common:option} redefined
            Foo = ${Common:Option} Redefined
        c                     | S r   r!   )r   s    r   r  z[ConfigParserTestCaseExtendedInterpolation.test_case_sensitivity_conflicts.<locals>.<lambda>1  s    # r   )r  r  r   rW   r   r  r  r  r  r  rQ   r	  r   r  )r   r   r  r~   r=   r   r<   ru   r  s       r   test_case_sensitivity_conflictszIConfigParserTestCaseExtendedInterpolation.test_case_sensitivity_conflicts  s    oo   UW 	 |@@A 	&%B	& __So_>
2h<!7+
2h<!7+
2h<!#34
2h<!#34
2h< 12
2h< :;	& 	&s   CC!c                    | j                  d      }| j                  t        j                        5  |d   d    d d d        | j                  t        j                        5  |d   d    d d d        | j                  t        j                        5  |d   d    d d d        | j                  t        j                        5  |d   d    d d d        | j                  t        j                        5  |d   d    d d d        | j                  t
              5  d|d   d	<   d d d        y # 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   `xY w# 1 sw Y   y xY w)
Na   
            [interpolation fail]
            case1 = ${where's the brace
            case2 = ${does_not_exist}
            case3 = ${wrong_section:wrong_value}
            case4 = ${i:like:colon:characters}
            case5 = $100 for Fail No 5!
        zinterpolation failcase1case2case3case4case5zBLACK $ABBATHcase6)r<   r~   r=   InterpolationSyntaxErrorr_  r   r   s     r   test_other_errorsz;ConfigParserTestCaseExtendedInterpolation.test_other_errors:  sg   __   |DDE 	.#$W-	.|KKL 	.#$W-	.|KKL 	.#$W-	.|DDE 	.#$W-	.|DDE 	.#$W-	.z* 	@0?B#$W-	@ 	@	. 	.	. 	.	. 	.	. 	.	. 	.	@ 	@sG   	D)!	D5	E	E1	E	E%)D25D>E
EE"%E.)NN)r   r   r   r=   rz  r4   r  r2   r1   r0   r<   r  r  r  r  r  r  r!   r   r   r  r    sN    ,,L6L668MOF+'Z "E*A0<6@r   r  c                       e Zd ZdZy)ConfigParserTestCaseNoValueTN)r   r   r   r*   r!   r   r   r  r  R  s    Nr   r  c                   @    e Zd Zej                  ZdhZdhZdZd Z	d Z
y)ConfigParserTestCaseTrickyFiler$   r'   Tc                 "   t        j                  dd      }| j                         }| j                  t	        |j                  |d            d       | j                  |j                         g d       | j                  |j                  | j                  dd	d
i      d       | j                  t              5  |j                  | j                  ddd	d
i       d d d        | j                  t	        |j                  dd      j                  d            d       | j                  t	        |j                  dd      j                  d            d       d}| j                  |j                  |d             | j                  |j                  |d      d       | j                  t	        |j                  d            d       | j                  t         j"                        5  |j                  d       d d d        | j                  |j                  dd      d       | j                  |j                  dd      |j                  dd             | j                  |j                  d d      d!       y # 1 sw Y   xY w# 1 sw Y   xY w)"Nr   r   r   r   r   r   )strange
corruption&yeah, sections can be indented as wellanother one!no values heretricky interpolationmore interpolationgointerpolatez-1rg   T)rawrh   r  otherr     r   rW   r  r!  zare they subsectionszlets use some Unicodeu	   片仮名r"  r   r#  r$  letszdo thisr%  zgo shopping)r   r   r7   ru   rw   r!  rt   rz   r1   r~   r   ry   splitr   r}   r   r=   r_  )r   r   r;   longnames       r   test_cfgparser_dot_3z3ConfigParserTestCaseTrickyFile.test_cfgparser_dot_3\  s&   !!-E^^RWWVgW>?C )? 	@ 	4#7#7)6(= # ?@B	Dz* 	2IId**Dd)40  2	2 	RVVIw7==dCDaHRVVL':@@FGL;x1GHI*ABKPRXXn56:|KKL 	'HH%&	' 6?K 6? 6=	? 4f=}M!	2 	2	' 	's   ;"I8'J8JJc                     t        j                  dd      }| j                         }| j                  t              5  |j                  |d       d d d        y # 1 sw Y   y xY w)Nr   r   r   asciir   )r   r   r7   r~   UnicodeDecodeErrorr!  )r   r   r;   s      r   test_unicode_failurez3ConfigParserTestCaseTrickyFile.test_unicode_failure|  sT    !!-E^^12 	.GGFWG-	. 	. 	.   AA#N)r   r   r   r=   rz  r4   r+   r,   r*   r/  r3  r!   r   r   r  r  V  s-    ,,LJuNN@.r   r  c                   &    e Zd ZdZdZd Zd Zd Zy)Issue7005TestCasezrTest output when None is set() as a value and allow_no_value == False.

    http://bugs.python.org/issue7005

    z[section]
option = None

c                      |d      }|j                  d       |j                  ddd        t        j                         }|j	                  |       |j                         S NF)r*   r   r   )r   r   r   r   r
  r  )r   r4   cpr   s       r   preparezIssue7005TestCase.prepare  sJ    /
y!
y(D)kkm
||~r   c                     t        j                  d      }|j                  d       | j                  t              5  |j                  ddd        d d d        y # 1 sw Y   y xY wr8  )r=   rz  r   r~   ri  r   )r   r9  s     r   test_none_as_value_stringifiedz0Issue7005TestCase.test_none_as_value_stringified  sQ    &&e<
y!y) 	.FF9h-	. 	. 	.r4  c                 z    | j                  t        j                        }| j                  || j                         y r   )r:  r=   rP  ru   expected_output)r   r  s     r   "test_none_as_value_stringified_rawz4Issue7005TestCase.test_none_as_value_stringified_raw  s,    l::;!5!56r   N)r   r   r   __doc__r>  r:  r<  r?  r!   r   r   r6  r6    s     5O.7r   r6  c                       e Zd ZeZd Zy)SortedTestCasec                     | j                  d      }t        j                         }|j                  |       | j	                  |j                         d       y )Nz [b]
o4=1
o3=2
o2=3
o1=4
[a]
k=v
z,[a]
k = v

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

)r<   r   r   r
  ru   r  )r   r;   r  s      r   test_sortedzSortedTestCase.test_sorted  sJ    __ % & 
*&	'r   N)r   r   r   r   r/   rD  r!   r   r   rB  rB    s    I'r   rB  c                   2    e Zd Zej                  ZdZdZd Zy)CompatibleTestCasez#;r&   c                    t        j                  d      }| j                  |      }| j                  |j	                  dd      d       | j                  |j	                  dd      d       | j                  |j	                  dd      d       y )	Nz        [Commented Bar]
        baz=qwe ; a comment
        foo: bar # not a comment!
        # but this is a comment
        ; another comment
        quirk: this;is not a comment
        ; a space must precede an inline comment
        rD   rQ   zbar # not a comment!rO   rP   quirkzthis;is not a comment)r   r   r<   ru   ry   r   s      r   test_comment_handlingz(CompatibleTestCase.test_comment_handling  s|      )  __]+7/	17?90	2r   N)	r   r   r   r=   rP  r4   r,   r-   rI  r!   r   r   rF  rF    s    //L!2r   rF  c                   ,    e Zd Zej                  ZddZy)CopyTestCaseNc                 L   | j                  |      }|j                  |       | j                         }|j                  |       |j                         D ]M  }|j                  | j
                  k(  r|| j
                     j                         D ]  \  }}||   |k(  s||=  O |S r   )r7   r9   r   r   rx   r1   r   )r   r:   r)   r;   cf_copyr   r-  rW   s           r   r<   zCopyTestCase.fromstring  s    ^^H%
v.."" ~~' 	)G||t333"$T%9%9":"@"@"B )7#u,()	) r   r   )r   r   r   r=   rz  r4   r<   r!   r   r   rK  rK    s    ,,Lr   rK  c                       e Zd Zd Zd Zy)FakeFilec                     t        j                  dd      }t        |d      5 }|j                         | _        | j                  j                          d d d        y # 1 sw Y   y xY w)Nr  r   r   r   r   )r   r   r   	readlineslinesreverse)r   	file_pathr   s      r   __init__zFakeFile.__init__  sR    $$]<H	)g. 	!!DJJJ 	! 	! 	!s   0AA'c                 b    t        | j                        r| j                  j                         S yr  )rw   rR  popr   s    r   r   zFakeFile.readline  s!    tzz?::>>##r   N)r   r   r   rU  r   r!   r   r   rO  rO    s    !r   rO  c              #   `   K   | j                         }|r| | j                         }|ryyw)z+As advised in Doc/library/configparser.rst.N)r   )r   lines     r   readline_generatorrZ    s)     ::<D

zz| s   )..c                   $    e Zd Zd Zd Zd Zd Zy)ReadFileTestCasec                    t        j                  dd      g}	 |j                  |d   j                  d             |D ]|  }t        j                         }t        |d      5 }|j                  |       d d d        | j                  d|       | j                  d	|d          | j                  |d   d	   d
       ~ y # t        $ r Y w xY w# 1 sw Y   ZxY w)Nr  r   r   r   utf8r   r   rE   rQ   r  )r   r   rr   r'  UnicodeEncodeErrorr=   rz  r   r   assertInru   )r   
file_pathsrT  r   r   s        r   	test_filezReadFileTestCase.test_file  s    &&}\JK
	jm226:; $ 	AI!..0Fi'2 $a  #$MM)V,MM%	!23VI.u5x@	A " 		$ $s   #B? #C?	C
CC	c                 0   t        j                  d      j                         j                  d      }t	        j
                         }|j                  |       | j                  d|       | j                  d|d          | j                  |d   d   d       y )Nz%
        [Foo Bar]
        foo=newbarr  rE   rQ   r  )	r   r   r  r-  r=   rz  r   r`  ru   )r   rR  r   s      r   test_iterablezReadFileTestCase.test_iterable  s     ! uwuuT{ 	 **,i(eVI./	*518<r   c                 t   t        j                         }| j                  t              5  |j	                  t                      ddd       |j	                  t        t                            | j                  d|       | j                  d|d          | j                  |d   d   d       y# 1 sw Y   kxY w)zIssue #11670.NrE   rQ   r  )	r=   rz  r~   ri  r   rO  rZ  r`  ru   r   r   s     r   test_readline_generatorz(ReadFileTestCase.test_readline_generator  s    **,y) 	)XZ(	)+HJ78i(eVI./	*518<	) 	)s   B..B7c                    t        j                  d      j                         j                  d      }t	        j
                         }| j                  t        j                        5 }|j                  |d       ddd       | j                  t        j                        d       t        j                  d      j                         j                  d      }t	        j
                         }| j                  t        j                        5 }|j                  |d       ddd       | j                  t        |j                        d       t        j                  d	      j                         j                  d      }t	        j
                         }| j                  t        j                        5 }|j                  |d       ddd       | j                  t        |j                        d
       t        j                  d      j                         j                  d      }t	        j
                         }| j                  t        j                        5 }|j                  |d       ddd       | j                  t        |j                        d       y# 1 sw Y   "xY w# 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   UxY w)zIssue #18260.z"
        [badbad]
        [badbad]r  s   badbadr   NzGWhile reading from b'badbad' [line  2]: section 'badbad' already existsz5
        [badbad]
        bad = bad
        bad = badzWWhile reading from b'badbad' [line  3]: option 'bad' in section 'badbad' already existsz
        [badbad]
        = badz=Source contains parsing errors: b'badbad'
	[line  2]: '= bad'z"
        [badbad
        bad = badzDFile contains no section headers.
file: b'badbad', line: 1
'[badbad')r   r   r  r-  r=   rz  r~   r   r   ru   r  r   r   r   r   )r   rR  r   dses       r   test_source_as_bytesz%ReadFileTestCase.test_source_as_bytes  sQ    ! UWUU4[ 	 **,|AAB 	6cU95	6	

  !  egeeDk 	 **,|@@A 	6SU95	6&	

  ! %'%%+ 	 **,|889 	6SU95	6M	
  ! egeeDk 	 **,|EEF 	6#U95	6	
G	6 	6	6 	6	6 	6	6 	6s0   &JJ'2J4K J$'J14J= K	N)r   r   r   rb  rd  rg  rj  r!   r   r   r\  r\    s    A==-
r   r\  c                   :    e Zd ZdZd Zd Zd Zd Zd Zd Z	d Z
y	)
CoverageOneHundredTestCasez"Covers edge cases in the codebase.c                 ~   t        j                  dd      }| j                  |j                  d       | j                  |j                  d       | j                  |j
                  d        | j                  |j                  d        | j                  |j                  d       | j                  t        |      d       y )Nr   r   )r   r   NNz3Option 'option' in section 'section' already exists)	r=   r   ru   r   r   r   linenor   r  r   r   s     r   test_duplicate_option_errorz6CoverageOneHundredTestCase.test_duplicate_option_errorK  s    11)XF	2x0t,t,%FGU &6 	7r   c                     t        j                  ddd      }| j                  |j                  d       | j                  |j                  d       | j                  |j
                  d       y )Nr   r   rawval)r   r   rr  )r=   rX  ru   r   r   r   ro  s     r   test_interpolation_depth_errorz9CoverageOneHundredTestCase.test_interpolation_depth_errorU  sV    44Xy5=?%DEx0	2r   c                 F   | j                  t              5 }t        j                          d d d        t        j                  d      }| j	                  |j
                  d       t        j                  d      }| j	                  |j
                  d       y # 1 sw Y   mxY w)Nr   r   )r~   ri  r=   r   ru   r   )r   r   r   s      r   test_parsing_errorz-CoverageOneHundredTestCase.test_parsing_error\  s{    y) 	(R%%'	()):x0))(3x0	( 	(s   BB c                    t        j                         }|j                  d       | j                  t         j                        5 }|d   d    d d d        | j                  t        j                        d       | j                  t         j                        5 }|d   d    d d d        | j                  t        |j                        d       y # 1 sw Y   xY w# 1 sw Y   ;xY w)Nz
            [section]
            invalid_percent = %
            invalid_reference = %(()
            invalid_variable = %(does_not_exist)s
        r   invalid_percentz.'%' must be followed by '%' or '(', found: '%'invalid_referencez+bad interpolation variable reference '%(()')r=   rz  r9   r~   r  ru   r  r   r   r   r   s      r   test_interpolation_validationz8CoverageOneHundredTestCase.test_interpolation_validationd  s    **,  	 |DDE 	19/0	1R\\* -> 	?|DDE 	3912	3R\\* -? 	@	1 	1	3 	3s   	C	CCC&c                 :   t        j                  d      5 }t        j                  dt               t	        j
                          d d d        | j                  t              d       |D ]"  }| j                  |j                  t               $ y # 1 sw Y   LxY w)NT)recordalwaysr   )
r  r  r  r  r=   rZ  assertGreaterEqualrw   r   category)r   r  warnings      r   $test_legacyinterpolation_deprecationz?CoverageOneHundredTestCase.test_legacyinterpolation_deprecationu  s    $$D1 	/Q!!(,>?,,.	/ 	A* 	@GMM'**,>?	@		/ 	/s   /BBc                     t        j                         }|j                  d       | j                  t	        |d         d       y )Nz7
            [section]
            key = value
        r   z<Section: section>)r=   rz  r9   ru   reprrf  s     r   test_sectionproxy_reprz1CoverageOneHundredTestCase.test_sectionproxy_repr}  s@    **,  	 	fY/02FGr   c                 N   t        j                         }dd l}|j                  |j                  d<   |j                  d       | j                  d|j                         | j                  |j                  dd      d       | j                  |j                  dd      d	       | j                  |d   j                  d      d       | j                  |d   j                  d      d	       |`| j                  t              5  |j                  dd       d d d        | j                  d|j                         |j                  d= | j                  d|j                         | j                  t              5  |j                  dd       d d d        | j                  t              5  |d   j                  d       d d d        | j                  t              5  |d   j                  d       d d d        y # 1 sw Y   xY w# 1 sw Y   zxY w# 1 sw Y   TxY w# 1 sw Y   y xY w)
Nr   decimalzS
            [s1]
            one = 1
            [s2]
            two = 2
        s1r  r   s2r  r  )r=   rz  r  Decimal
convertersr9   r`  ru   
getdecimalr~   r   rF  )r   r   r  s      r   "test_inconsistent_converters_statez=CoverageOneHundredTestCase.test_inconsistent_converters_state  s   **,'.)$  	 	i!2!23**47;**47;007;007;~. 	+dE*	+i!2!23i(F$5$56~. 	+dE*	+~. 	+4L##E*	+~. 	+4L##E*	+ 	+	+ 	+
	+ 	+	+ 	+	+ 	+s0   G77H'HH7H HHH$N)r   r   r   r@  rp  rs  ru  rz  r  r  r  r!   r   r   rl  rl  H  s+    ,731@"@H+r   rl  c                   R    e 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y)ExceptionPicklingTestCasezBTests for issue #13760: ConfigParser exceptions are not picklable.c                 J   dd l }t        j                  d      }t        |j                  dz         D ]o  }|j                  ||      }|j                  |      }| j                  |j                  |j                         | j                  t        |      t        |             q y )Nr   rW   r   )
pickler=   Errorr   HIGHEST_PROTOCOLdumpsloadsru   messager  r   r  e1protopicklede2s         r   
test_errorz$ExceptionPicklingTestCase.test_error  s    (622Q67 	1Ell2u-Gg&BRZZ4T"XtBx0		1r   c                    dd l }t        j                  d      }t        |j                  dz         D ]  }|j                  ||      }|j                  |      }| j                  |j                  |j                         | j                  |j                  |j                         | j                  |j                  |j                         | j                  t        |      t        |              y )Nr   r   r   )r  r=   r   r   r  r  r  ru   r  r   r   r  r  s         r   test_nosectionerrorz-ExceptionPicklingTestCase.test_nosectionerror  s    ((3622Q67 	1Ell2u-Gg&BRZZ4RWWbgg.RZZ4T"XtBx0	1r   c                 0   dd l }t        j                  dd      }t        |j                  dz         D ]  }|j                  ||      }|j                  |      }| j                  |j                  |j                         | j                  |j                  |j                         | j                  |j                  |j                         | j                  |j                  |j                         | j                  t        |      t        |              y )Nr   r   r   r   )r  r=   r   r   r  r  r  ru   r  r   r   r   r  r  s         r   test_nooptionerrorz,ExceptionPicklingTestCase.test_nooptionerror  s    '')<622Q67 	1Ell2u-Gg&BRZZ4RWWbgg.RZZ4RYY		2T"XtBx0	1r   c                    dd l }t        j                  ddd      }t        |j                  dz         D ]  }|j                  ||      }|j                  |      }| j                  |j                  |j                         | j                  |j                  |j                         | j                  |j                  |j                         | j                  |j                  |j                         | j                  |j                  |j                         | j                  t        |      t        |              y )Nr   r   r   r   r   )r  r=   r   r   r  r  r  ru   r  r   r   r   rn  r  r  s         r   test_duplicatesectionerrorz4ExceptionPicklingTestCase.test_duplicatesectionerror  s    //	8SI622Q67 	1Ell2u-Gg&BRZZ4RWWbgg.RZZ4RYY		2RYY		2T"XtBx0	1r   c                    dd l }t        j                  dddd      }t        |j                  dz         D ].  }|j                  ||      }|j                  |      }| j                  |j                  |j                         | j                  |j                  |j                         | j                  |j                  |j                         | j                  |j                  |j                         | j                  |j                  |j                         | j                  |j                  |j                         | j                  t        |      t        |             1 y )Nr   r   r   r   r   r   )r  r=   r   r   r  r  r  ru   r  r   r   r   r   rn  r  r  s         r   test_duplicateoptionerrorz3ExceptionPicklingTestCase.test_duplicateoptionerror  s   ..y(H622Q67 		1Ell2u-Gg&BRZZ4RWWbgg.RZZ4RYY		2RYY		2RYY		2T"XtBx0		1r   c                 2   dd l }t        j                  ddd      }t        |j                  dz         D ]  }|j                  ||      }|j                  |      }| j                  |j                  |j                         | j                  |j                  |j                         | j                  |j                  |j                         | j                  |j                  |j                         | j                  t        |      t        |              y Nr   r   r   msgr   )r  r=   InterpolationErrorr   r  r  r  ru   r  r   r   r   r  r  s         r   test_interpolationerrorz1ExceptionPicklingTestCase.test_interpolationerror  s    ,,Xy%H622Q67 	1Ell2u-Gg&BRZZ4RWWbgg.RZZ4RYY		2T"XtBx0	1r   c                    dd l }t        j                  dddd      }t        |j                  dz         D ]  }|j                  ||      }|j                  |      }| j                  |j                  |j                         | j                  |j                  |j                         | j                  |j                  |j                         | j                  |j                  |j                         | j                  |j                  |j                         | j                  t        |      t        |              y )Nr   r   r   rr  r^  r   )r  r=   r_  r   r  r  r  ru   r  r   r   r   r^  r  r  s         r   $test_interpolationmissingoptionerrorz>ExceptionPicklingTestCase.test_interpolationmissingoptionerror  s    99(Ik#622Q67 	1Ell2u-Gg&BRZZ4RWWbgg.RZZ4RYY		2R\\2<<8T"XtBx0	1r   c                 2   dd l }t        j                  ddd      }t        |j                  dz         D ]  }|j                  ||      }|j                  |      }| j                  |j                  |j                         | j                  |j                  |j                         | j                  |j                  |j                         | j                  |j                  |j                         | j                  t        |      t        |              y r  )r  r=   r  r   r  r  r  ru   r  r   r   r   r  r  s         r   test_interpolationsyntaxerrorz7ExceptionPicklingTestCase.test_interpolationsyntaxerror  s    228YN622Q67 	1Ell2u-Gg&BRZZ4RWWbgg.RZZ4RYY		2T"XtBx0	1r   c                 2   dd l }t        j                  ddd      }t        |j                  dz         D ]  }|j                  ||      }|j                  |      }| j                  |j                  |j                         | j                  |j                  |j                         | j                  |j                  |j                         | j                  |j                  |j                         | j                  t        |      t        |              y )Nr   r   r   rr  r   )r  r=   rX  r   r  r  r  ru   r  r   r   r   r  r  s         r   test_interpolationdeptherrorz6ExceptionPicklingTestCase.test_interpolationdeptherror  s    11(I622Q67 	1Ell2u-Gg&BRZZ4RWWbgg.RZZ4RYY		2T"XtBx0	1r   c                 (   dd l }t        j                  d      }|j                  dd       |j                  dd       |j                  dd       t	        |j
                  dz         D ]  }|j                  ||      }|j                  |      }| j                  |j                  |j                         | j                  |j                  |j                         | j                  |j                  |j                         | j                  |j                  |j                         | j                  t        |      t        |              t        j                  d	      }|j                  dd       |j                  dd       |j                  dd       t	        |j
                  dz         D ]  }|j                  ||      }|j                  |      }| j                  |j                  |j                         | j                  |j                  |j                         | j                  |j                  |j                         | j                  |j                  |j                         | j                  t        |      t        |              y )
Nr   r   r   line1r  line2r  line3filename)r  r=   r   rr   r   r  r  r  ru   r  r   r   errorsr  r  s         r   test_parsingerrorz+ExceptionPicklingTestCase.test_parsingerror  s   &&x0
		!W
		!W
		!W622Q67 	1Ell2u-Gg&BRZZ4RWWbgg.RYY		2RYY		2T"XtBx0	1 &&z2
		!W
		!W
		!W622Q67 	1Ell2u-Gg&BRZZ4RWWbgg.RYY		2RYY		2T"XtBx0	1r   c                    dd l }t        j                  ddd      }t        |j                  dz         D ]  }|j                  ||      }|j                  |      }| j                  |j                  |j                         | j                  |j                  |j                         | j                  |j                  |j                         | j                  |j                  |j                         | j                  |j                  |j                         | j                  t        |      t        |              y )Nr   r  r   rY  r   )r  r=   r   r   r  r  r  ru   r  r   rY  r   rn  r  r  s         r   test_missingsectionheadererrorz8ExceptionPicklingTestCase.test_missingsectionheadererror/  s    33JVL622Q67 	1Ell2u-Gg&BRZZ4RWWbgg.RWWbgg.RYY		2RYY		2T"XtBx0	1r   N)r   r   r   r@  r  r  r  r  r  r  r  r  r  r  r  r!   r   r   r  r    s<    L1	1
111
11
11161r   r  c                       e Zd ZdZd Zy)InlineCommentStrippingTestCasez}Tests for issue #14590: ConfigParser doesn't strip inline comment when
    delimiter occurs earlier without preceding space..c                 
   t        j                  d      }|j                  d       |d   }| j                  |d   d       | j                  |d   d       | j                  |d	   d
       | j                  |d   d       | j                  |d   d       | j                  |d   d       | j                  |d   d       |d   }| j                  |d   d       | j                  |d   d       | j                  |d	   d       y )N)r&   r'   r  )r-   a  
        [section]
        k1 = v1;still v1
        k2 = v2 ;a comment
        k3 = v3 ; also a comment
        k4 = v4;still v4 ;a comment
        k5 = v5;still v5 ; also a comment
        k6 = v6;still v6; and still v6 ;a comment
        k7 = v7;still v7; and still v7 ; also a comment

        [multiprefix]
        k1 = v1;still v1 #a comment ; yeah, pretty much
        k2 = v2 // this already is a comment ; continued
        k3 = v3;#//still v3# and still v3 ; a comment
        r   k1zv1;still v1k2v2k3v3k4zv4;still v4k5zv5;still v5k6zv6;still v6; and still v6k7zv7;still v7; and still v7multiprefixzv3;#//still v3# and still v3)r=   rz  r9   ru   )r   cfgr  s      r   test_strippingz-InlineCommentStrippingTestCase.test_strippingA  s	   '' A   	 	N4-04$'4$'4-04-04"=>4"=>4-04$'4"@Ar   N)r   r   r   r@  r  r!   r   r   r  r  =  s    :Br   r  c                   .    e Zd ZdZd Zd Zd Zd Zd Zy)ExceptionContextTestCasezO Test that implementation details doesn't leak
    through raising exceptions. c                 *   t        j                         }|j                  d       | j                  t         j                        }|5  |j                  dd       d d d        | j                  |j                  j                  d       y # 1 sw Y   0xY w)Nz
        [Paths]
        home_dir: /Users
        my_dir: %(home_dir1)s/lumberjack
        my_pictures: %(my_dir)s/Pictures
        Pathsmy_dirT)	r=   rz  r9   r~   r_  ry   r   r   __suppress_context__ry  s      r   test_get_basic_interpolationz5ExceptionContextTestCase.test_get_basic_interpolatione  sy    **,  	 |KKL 	*JJw)	*bll77>	* 	*s   B		Bc                 R   t        j                  t        j                               }|j                  d       | j	                  t         j
                        }|5  |j                  dd       d d d        | j                  |j                  j                  d       y # 1 sw Y   0xY w)Nr  z
        [Paths]
        home_dir: /Users
        my_dir: ${home_dir1}/lumberjack
        my_pictures: ${my_dir}/Pictures
        r  r  T)
r=   rz  r  r9   r~   r_  ry   r   r   r  ry  s      r   test_get_extended_interpolationz8ExceptionContextTestCase.test_get_extended_interpolationr  s    **$::<>  	 |KKL 	*JJw)	*bll77>	* 	*s   BB&c                 $   t        j                         }|j                  d       | j                  t         j                        5 }|j                  d       d d d        | j                  j                  j                  d       y # 1 sw Y   0xY w)Nz2
        [Paths]
        home_dir: /Users
        rK  T)	r=   rz  r9   r~   r   r   r   r   r  ry  s      r   test_missing_optionsz-ExceptionContextTestCase.test_missing_options  st    **,  	 |::; 	#rNN6"	#bll77>	# 	#s   BBc                    t        j                         }| j                  t         j                        5 }|j	                  ddd       d d d        | j                  j                  j                  d       y # 1 sw Y   0xY w)NSection1an_int15T)r=   rz  r~   r   r   r   r   r  r   r   r   s      r   test_missing_sectionz-ExceptionContextTestCase.test_missing_section  sc    **,|::; 	3rJJz8T2	3bll77>	3 	3s   A77B c                    t        j                         }| j                  t         j                        5 }|j	                  dd       d d d        | j                  j                  j                  d       y # 1 sw Y   0xY w)Nr  r  T)r=   rz  r~   r   r   r   r   r  r  s      r   test_remove_optionz+ExceptionContextTestCase.test_remove_option  sc    **,|::; 	7r  X6	7bll77>	7 	7s   A66A?N)	r   r   r   r@  r  r  r  r  r  r!   r   r   r  r  a  s     $?????r   r  c                   B     e Zd ZdZej
                  Zd fd	Zd Z xZ	S )ConvertersTestCasez Introduced in 3.5, issue #18159.c                 H    t         |   |      }d |j                  d<   |S )Nr   c                     | j                         D cg c]"  }|j                         r|j                         $ c}S c c}w r   )r-  r  )vr   s     r   r  z.ConvertersTestCase.newconfig.<locals>.<lambda>  s2    AGGI 1?q45GGI 23 1?  1?s   '=rv   )superr7   r  )r   r)   r6   	__class__s      r   r7   zConvertersTestCase.newconfig  s,    7$h$7'?F#r   c                    | j                         }| j                  d|j                         | j                  d|j                         | j                  |j                  d          | j                  |j                  d          | j                  |j                  d          | j	                  |j                  d          | j                  t        |j                        d       | j                  t              5  d |j                  d<   d d d        | j                  t              5  d |j                  d <   d d d        |j                  d	       |d
   }| j                  |d   d       | j                  |d   d       | j                  |d   d       | j                  |d   d       | j                  |d   d       | j                  |j                  d
d      d       | j                  |j                  d
d      d       | j                  |j                  d
d      d       | j                  |j                  d
d      d       | j                  |j                  d
d      d       | j                  |j                  d
d      d       | j                  |j                  d
d      d       | j                  |j                  d
d      d       | j                  |j                  d
d      g d       | j                  |j                  d
d      d       | j                  |j                  d      d       | j                  |j                  d      d       | j                  |j                  d      d       | j                  |j                  d      g d       | j                  |j                  d      d       | j                  t              5  |j!                  d
d       d d d        | j                  t              5  |j!                  d       d d d        dd l}|j$                  |j                  d<   | j                  d|j                         | j	                  |j                  d          | j                  t        |j                        d       |j%                  d      }| j                  |j!                  d
d      |       | j                  |j!                  d      |       |j                  d= | j'                  d|j                         | j                  t        |j                        d       | j                  t              5  |j!                  d
d       d d d        | j                  t              5  |j!                  d       d d d        | j                  t(              5  |j                  d= d d d        | j                  t(              5  |j                  d= d d d        | j                  t(              5  |j                  d = d d d        y # 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   RxY w# 1 sw Y   0xY w# 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   y xY w)Nr_   rv   rZ   r]   r+  c                     | S r   r!   r  s    r   r  z4ConvertersTestCase.test_converters.<locals>.<lambda>  s    1 r   r  c                     | S r   r!   r  s    r   r  z4ConvertersTestCase.test_converters.<locals>.<lambda>  s    Q r   z~
        [s]
        str = string
        int = 1
        float = 0.5
        list = a b c d e f g
        bool = yes
        r  r  r:   rm   z0.5za b c d e f gboolrk   r   g      ?)r   r   cdr   r   gTr   r  r   )r7   r`  r  r  assertIsNotNoneru   rw   r~   r   r9   ry   rz   r|   getlistr}   r   r  r  r  rF  r   )r   r  r  r  dec0_5s        r   test_convertersz"ConvertersTestCase.test_converters  sD   nni0fcnn-#../0#..12#..34S^^F34S^^,a0z* 	-!,CNN2	-z* 	/#.CNN4 	/  	 H58,53'7U+6O46E*e,h7e,c2g.6f-?f-u5e,h7C/3c73S9S&1 4C 	DV4d;ux0%!,G,c26* -< 	=f-t4~. 	)NN3(	)~. 	"LL!	"$+OOy!i0S^^I67S^^,a0'W5v>g.7NN9%CNN3S^^,a0~. 	)NN3(	)~. 	"LL!	"x( 	*y)	*x( 	#r"	#x( 	%t$	% 	%u	- 	-	/ 	/B	) 	)	" 	"	) 	)	" 	"	* 	*	# 	#	% 	%sl   ;X)X)X6YY Y/Y(Y4Z X&)X36Y YYY%(Y14Y= Z	r   )
r   r   r   r@  r=   rz  r4   r7   r  __classcell__r  s   @r   r  r    s    *,,LD%r   r  c                   ,    e Zd ZdZdZd Zd Zd Zd Zy)!BlatantOverrideConvertersTestCasez}What if somebody overrode a getboolean()? We want to make sure that in
    this case the automatic converters do not kick in.z
        [one]
        one = false
        two = false
        three = long story short

        [two]
        one = false
        two = false
        three = four
    c                     t        j                  dt        i      }|j                  | j                         | j                  |       | j                  |j                  d          y )Nrw   )r  )r=   rz  rw   r9   r   	_test_lenr  r  r   r  s     r   test_converters_at_initz9BlatantOverrideConvertersTestCase.test_converters_at_init  sI    ''E3<@$sS^^E23r   c                     G d dt         j                        } |       }|j                  | j                         | j	                  |       | j                  |j                  d          | j                  |j                  dd             | j                  |j                  dd             | j                  |j                  dd             | j                  |j                  dd             |j                  |j                  d<   | j                  |j                  dd             | j                  |j                  dd             | j                  |j                  dd             | j                  |j                  dd             y )Nc                   d     e Zd ZdZddej
                  d fd
Zddej
                  ddZ xZS )OBlatantOverrideConvertersTestCase.test_inheritance.<locals>.StrangeConfigParserz0a historic borough in south central PennsylvaniaFNr)  rh   rf   c                8    ||k(  ryt         |   |||||      S )NTr  )r  r}   )r   r   r   r)  rh   rf   r  s         r   r}   zZBlatantOverrideConvertersTestCase.test_inheritance.<locals>.StrangeConfigParser.getboolean  s0    f$w)'6s3; * = =r   c                8    | j                  ||t        |||      S )Nr  )	_get_convrw   )r   r   r   r)  rh   rf   s         r   getlenzVBlatantOverrideConvertersTestCase.test_inheritance.<locals>.StrangeConfigParser.getlen	  s%    ~~gvs$/7 & 9 9r   )	r   r   r   
gettysburgr=   r@   r}   r  r  r  s   @r   StrangeConfigParserr     s5    KJ9>T!-!4!4= 6; , 3 39 9r   r  rw   r  r  r_   )r=   rz  r9   r   r  r  r  r   r}   r   _convert_to_boolean)r   r  r  s      r   test_inheritancez2BlatantOverrideConvertersTestCase.test_inheritance  s)   	9,";"; 	9 "#$s#../0ue45ue45u56u56$'$;$;y!u56u56u56u56r   c                 Z   | j                  t        |j                        d       | j                  d|j                         | j                  d|j                         | j	                  d|j                         | j                  |j                  d          | j                  |j                  d          | j                  |j                  d          | j                  |j                  dd      d       | j                  |j                  dd	      d       | j                  |j                  dd
      d       | j                  |j                  d	d      d       | j                  |j                  d	d	      d       | j                  |j                  d	d
      d       | j                  |j                  d	dd      d       | j                  t        j                        5  |j                  d	d       d d d        | j                  |d   j                  d      d       | j                  |d   j                  d	      d       | j                  |d   j                  d
      d       | j                  |d	   j                  d      d       | j                  |d	   j                  d	      d       | j                  |d	   j                  d
      d       | j                  |d	   j                  dd      d       | j                  |d	   j                  d      d        y # 1 sw Y   ,xY w)Nr+  r_   rw   tysburgrZ   r]   r  r   r  r     fourr   re   )
ru   rw   r  r`  rF  r  r  r~   r=   r   r  s     r   r  z+BlatantOverrideConvertersTestCase._test_len  s   S^^,a0i0eS^^,CNN3#../0#..12#..34E5115E5115E73R8E5115E5115E73Q7E6A>B|99: 	&JJuf%	&U**5115U**5115U**73R8U**5115U**5115U**73Q7U**615q9U**62D9	& 	&s   #L  L*c                    t        j                         d _        fd_        j	                  | j
                         | j                  t        j                        d       | j                  dj                         | j                  dj                         | j                  j                  d          | j                  j                  d          | j                  j                  d          | j                  j                  dd             | j                  j                  d	d	             | j                  j                  dd	             | j                  j                  d	d             j                  j                  d<   | j                  j                  dd             | j                  j                  d	d	             | j                  j                  dd	             | j                  j                  d	d             | j                  j                  dd      d
       | j                  j                  dd	      d
       | j                  j                  dd      d       | j                  j                  d	d      d
       | j                  j                  d	d	      d
       | j                  j                  d	d      d       | j                  t               5  | j                  d   j                  d      d
       d d d        | j                  t               5  | j                  d	   j                  d      d
       d d d        y # 1 sw Y   LxY w# 1 sw Y   y xY w)Nc                      y)NTr!   )r   r   s     r   r  zLBlatantOverrideConvertersTestCase.test_instance_assignment.<locals>.<lambda>8  s    r   c                 &    t        |    |         S r   )rw   )r   r   r  s     r   r  zLBlatantOverrideConvertersTestCase.test_instance_assignment.<locals>.<lambda>9  s    SWf1E-F r   r  r_   rw   rZ   r]   r  r  r   r  r  r+  )r=   rz  r}   r  r9   r   ru   rw   r  r`  rF  r  r   r  r   r~   r   r  s    @r   test_instance_assignmentz:BlatantOverrideConvertersTestCase.test_instance_assignment6  s   '')5F
$S^^,a0i0/#../0#..12#..34ue45ue45ue45ue45$'$;$;y!u56u56u56u56E5115E5115E73R8E5115E5115E73Q7 ~. 	:SZ..u5q9	:~. 	:SZ..u5q9	: 	:	: 	:	: 	:s   <%M,>%M8,M58NN)	r   r   r   r@  r   r  r   r  r  r!   r   r   r  r    s"    :
F47::4:r   r  c                       e Zd Zd Zy)MiscTestCasec                 >    t        j                  | t        dh       y )Nr  )not_exported)r   check__all__r=   r   s    r   test__all__zMiscTestCase.test__all__Y  s    T<wiHr   N)r   r   r   r  r!   r   r   r
  r
  X  s    Ir   r
  __main__).collectionsr=   r   r  r   unittestr  rK  r   test.supportr   UserDictr   r#   rB   TestCaserO  rR  r|  r  r  r  r  r  r  r  r  r  r  r  r6  rB  rF  rK  rO  rZ  r\  rl  r  r  r  r  r  r
  r   mainr!   r   r   <module>r     sq     	 	     "%% . B@8* @8F]H$5$5 
_L=(*;*; _LD!"-9J9J !"H@.B @0C83D3D C*0D * 4H  DmX->-> D:0CmX->-> 0Cf*3J *I#98;L;L I(h@x?P?P h@V"6 *.%;X=N=N *.Z7)) 7:', '.2/1B1B 2,=("3"3 &
 
P
x(( P
fW+!2!2 W+tX1 1 1 X1v!BX%6%6 !BH3?x00 3?lO%(9(9 O%dl:(9(9 l:^I8$$ I
 zHMMO r   