Your IP : 216.73.216.213


Current Path : /opt/alt/python34/lib64/python3.4/test/__pycache__/
Upload File :
Current File : //opt/alt/python34/lib64/python3.4/test/__pycache__/test_configparser.cpython-34.pyo

�
f f��@sddlZddlZddlZddlZddlZddlZddlZddlZddlm	Z	Gdd�dej
�ZGdd�d�ZGdd�de�Z
Gd	d
�d
e
ej�ZGdd�de
ej�ZGd
d�de
ej�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de
ej�ZGdd�de
ej�ZGdd�de�ZGdd�deej�ZGdd�de
ej�ZGdd �d e�ZGd!d"�d"eej�ZGd#d$�d$ej�ZGd%d&�d&e�ZGd'd(�d(eej�ZGd)d*�d*e
ej�ZGd+d,�d,�Z d-d.�Z!Gd/d0�d0ej�Z"Gd1d2�d2ej�Z#Gd3d4�d4ej�Z$Gd5d6�d6ej�Z%e&d7krej'�ndS)8�N)�supportc@s^eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�ZeZ	d
S)�
SortedDictcCst|jj��S)N)�sorted�data�items)�self�r�;/opt/alt/python34/lib64/python3.4/test/test_configparser.pyrszSortedDict.itemscCst|jj��S)N)rr�keys)rrrr	r
szSortedDict.keyscCsdd�|j�D�S)NcSsg|]}|d�qS)�r)�.0�irrr	�
<listcomp>s	z%SortedDict.values.<locals>.<listcomp>)r)rrrr	�valuesszSortedDict.valuescCst|j��S)N)�iterr)rrrr	�	iteritemsszSortedDict.iteritemscCst|j��S)N)rr
)rrrr	�iterkeysszSortedDict.iterkeyscCst|j��S)N)rr)rrrr	�
itervaluesszSortedDict.itervaluesN)
�__name__�
__module__�__qualname__rr
rrrr�__iter__rrrr	rsrc@smeZdZdZdZd
ZdZdZej	Z
dZejZ
ejZddd	�Zdd
d�ZdS)�CfgParserTestCaseClassF�=�:�;�#TNcCsstd|d|jd|jd|jd|jd|jd|jd|jd	|jd
|j	�
}|j
|�}|S)N�defaults�allow_no_value�
delimiters�comment_prefixes�inline_comment_prefixes�empty_lines_in_values�	dict_type�strict�default_section�
interpolation)�dictrrr r!r"r#r$r%r&�config_class)rrZ	arguments�instancerrr	�	newconfig.s								z CfgParserTestCaseClass.newconfigcCs |j|�}|j|�|S)N)r*�read_string)r�stringr�cfrrr	�
fromstring>s
z!CfgParserTestCaseClass.fromstring)rr)rr)rr)rrrrrr r!r"�configparser�
_default_dictr#r$ZDEFAULTSECTr%�_UNSETr&r*r.rrrr	r#s			rc@seZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)S)*�
BasicTestCasec	oCs�ddddddddd	g	}|jr:|jd
�n|j�d>d?g}|j�}|j�|j}|||�|jd�}|j�|||�dd�|D�}|j�|j|j�|j�|||�|dj�}tt|��}|||�|j�}tt|��}|jt	|�t	|��x$|D]\}}|||j
�qVW||j�||j�||jdd
�d�||jdd
�d�||jdd
�d�||jdd�d�||jdd
�d�||jdd�d�||jdd�d�||jdd�d�||j
d	d�d�||jd	d�d�|j|jd	d�d�||jd	d�d�||jd	d�d�||jd	d �d!�|jr||jd
d"�d�n||jdd
d#d�d�||jdd
d$idd
6�d�|jtj��|jd%d
�WdQX|jtj��|jdd&�WdQX||jd%d
d#d�d�||jdd&d#d�d�||jdd
d#d�d�||jd'd
d#d�d�||j
d	dd#d(�d�||j
d	d)d#d(�d(�||j
d	d)d#d*�d*�|jtj��|j
d	d)�WdQX|j|jd	dd#d+�d�|j|jd	d,d#d+�d+�||jd	d,d#d-�d-�|jtj��|jd	d,�WdQX||jd	dd#d.�d�||jd	d/d#d0�d0�||jd	d/d#d.�d.�|jtj��|jd	d/�WdQX||jd1dd#d.�d.�|jr*||jd
d"d#d�d�||jd
d2d#d�d�n||dd
d�||dd
d�|d}||j
d�|j|j|�|jt��d3|_
WdQX|jt��d4|_WdQX||d
d�||dd�||dd
d�||ddd�||ddd�||ddd�||dd
d5�|jrk||d
d"d�n||djd
d�d�||djd
d#d�d�||djd
d$idd
6�d�|jt��|d%d
WdQX|jt��|dd&WdQX|jt��|d%jd
d#d�WdQX||djd&d�d�||djd&d#d�d�||djd&�d�||djd
d�d�||djd
d#d�d�|jt��|d'jd
d�WdQX||d	j
dd(�d�||d	j
dd#d(�d�||d	j
d)d(�d(�||d	j
d)d#d(�d(�||d	j
d)d*�d*�||d	j
d)d#d*�d*�||d	j
d)�d�|j|d	jdd+�d�|j|d	jdd#d+�d�|j|d	jd,d+�d+�|j|d	jd,d#d+�d+�||d	jd,d-�d-�||d	jd,d#d-�d-�||d	jd,�d�||d	jdd.�d�||d	jdd#d.�d�||d	jd/d0�d0�||d	jd/d#d0�d0�||d	jd/d.�d.�||d	jd/d#d.�d.�||d	jd/�d�|jr||d
jd"d�d�||d
jd"d#d�d�||d
jd2d�d�||d
jd2d#d�d�nd6||jd7<d8||jd9<|j|jd��|j|jdd��|j|jd��|j|j|j��|j|jdd
�d:�|j|jdd
�d;�|j|jdd
�d<�|j|jdd7��|j|jdd7��|j|j|jd7��|j|jdd7��|j|j|jd7��|jtj��}|jd=d
�WdQX|j|jjd@�||jdd
�d5�|d	=|jd	|k�|jt��|d	=WdQX|jt ��||j=WdQX|dd
=|jd
|dk�|jt��|dd
=WdQX|jd9|dk�|jt��|dd9=WdQX||jd9=|jd9|dk�|jt��||jd9=WdQX|jt��|d=d
=WdQXdS)ANz
Commented BarzFoo BarzInternationalized Stuffz	Long LinezSection\with$weird%characters[	�Spacesz
Spacey BarzSpacey Bar From The Beginning�Types�NoValue�baz�qwe�foo�bar3cSsg|]}|�qSrr)r�sectionrrr	r`s	z,BasicTestCase.basic_test.<locals>.<listcomp>�bar1�bar2�bar4zkey with spaces�valuezanother with spaceszsplat!�int�*Z42�floatg)\��(�?z0.44�booleanFZ123zstrange but acceptablezoption-without-valueZfallback�varszNo Such Foo Barzno-such-foozNo Such Spacey Bar�zno-such-intZ18gz
no-such-floatz0.0Tzno-such-boolean�yesz
No Such Typeszno-such-option-without-valuezName is read-onlyzParser is read-onlyz7this line is much, much longer than my editor
likes it.�1Z
this_value�2Z
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)r6r7)r8r9)rH)!r�append�sort�sections�assertEqualrr%r�list�len�namer�get�getintZassertAlmostEqualZgetfloat�
getboolean�assertRaisesr/�NoSectionError�
NoOptionErrorZassertIs�parser�AttributeError�KeyError�
assertTrueZremove_section�assertFalse�
has_option�
remove_option�	exception�args�
ValueError)	rr-�E�F�L�eqrOr:�cmrrr	�
basic_testEsz		

	






	&

	
	 '      
 
   	 
zBasicTestCase.basic_testcCsdj|j|j�}|jr.|d7}n|j|�}|j|�|jr�|jtj	��'|j
tjdj|j���WdQX|jtj
��'|j
tjdj|j���WdQXnD|j
tjdj|j���|j
tjdj|j���dS)NaI[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
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
            )�formatrr rr.rer$rSr/�DuplicateOptionErrorr+�textwrap�dedent�DuplicateSectionError)r�
config_stringr-rrr	�
test_basic#s"	

	zBasicTestCase.test_basiccCs�i	idd6d6idd6d6idd6dd6d	6id
d6dd6d6idd6d
6id6idd6dd6dd6dd6d6idd6dd6d6idd6dd6d d!6d"d#6d$6}|jr�|jiidd%6d&6�n|j�}|j|�|j|�|jr�|jtj��.|jiidd'6d(6id)d*6d+6�WdQX|jtj	��'|jiid,d-6d.d/6d06�WdQXnK|jiidd'6d16id)d*6d26�|jiid,d-6d.d/6d06�dS)3Nr;r8zFoo Barr<z
Spacey Barr9r7r6zSpacey Bar From The Beginningr=z
Commented Barz7this line is much, much longer than my editor
likes it.z	Long LinezSection\with$weird%characters[	Z	Bulgarianzfoo[bg]ZDefaultZEnglishzfoo[en]ZDeutschzfoo[de]zInternationalized Stuffr>zkey with spaceszsplat!zanother with spacesr3r@r?g)\��(�?rAFrBzstrange but acceptable�{r4zoption-without-valuer5�keyrF�value2Zkey2rzwith a value�optionzwith another valueZOPTIONzDuplicate Options Herer:ZSECTION)
r�updater*�	read_dictrer$rSr/rjrg)r�configr-rrr	�test_basic_from_dictdsf		

					z"BasicTestCase.test_basic_from_dictcCs@|j�}|jd�|jd�|jd�|j�}|j�|j}||dddg�|jddd�||jd�dg�||jdd�dd�|jt	j
��|jddd�WdQX|j|jdd��|j
|jdd��|jddd�x*dD]"}|j|jd|�d�q(W||jd�d	g�||jd�dg�|jdd�||jd�g�|jd
j|jd��}||jd�dg�||jdd�d�|jdj|jd�didd6�}|j|jdd��dS)N�A�a�Br>�bz@could not locate option, expecting case-insensitive option names�A-Bz	A-B value�a-b�A-b�a-Bz9has_option() returned false for option which should existz3[MySection]
Option{} first line   
	second line   
r�	MySectionrp�Optionzfirst line
second linez[section]
nekey{}nevalue
rrnr:�Key)rzr{r|ry)r*�add_sectionrKrJrL�set�optionsrPrSr/rTrYr[rZr\r.rfr)rr-rbrc�optrrr	�test_case_sensitivity�sD



	
z#BasicTestCase.test_case_sensitivitycCs|j�}i|d<idd6|d<i|d<dd�|D�}|j�|j}|j}||tdd|jdg��||dj�dh�||dddd�|jt��d|dd<WdQX|j	d|dk�d	|dd
<x(dD] }|j	||dkd�qW||dj�dh�||dj�dh�|dd=||dj�i�|j
dj|jd��}||dj�dh�||ddd�|j
dj|jd�didd6�}|j	d|dk�dS)Nrur>rwrvcSsg|]}|�qSrr)rr:rrr	r�s	zFBasicTestCase.test_case_sensitivity_mapping_access.<locals>.<listcomp>rxz@could not locate option, expecting case-insensitive option namesz	A-B value�A-B�a-b�A-b�a-Bz9has_option() returned false for option which should existz3[MySection]
Option{} first line   
	second line   
rr}rpr~zfirst line
second linez[section]
nekey{}nevalue
rrnrr:)r�r�r�r�)
r*rJrLZassertCountEqualrr%r
rSrXrYr.rfr)rr-rbrcZelem_eqr�rrr	�$test_case_sensitivity_mapping_access�sB


		"

z2BasicTestCase.test_case_sensitivity_mapping_accesscCst|jidd6�}|j|j|jd�dd�|jidd6�}|j|j|jd�dd�dS)N�Barr8�Fooz@could not locate option, expecting case-insensitive option namesz<could not locate option, expecting case-insensitive defaults)r*rLrPr%)rr-rrr	�test_default_case_sensitivity�sz+BasicTestCase.test_default_case_sensitivitycCsP|j�}|j|tjdj|jd��|j|tjdj|jd��|j|tjd�}|j|jd�|j	sL|j|tjd�}|j|jd
�t
jd�}|jddkr�tj}|f}ntj}|dd	f}t|d
d��}|j|||�}WdQX|j|j|�ndS)Nz[Foo]
{}val-without-opt-name
rr�No Section!
�<???>z[Foo]
  wrong-indent
zcfgparser.3rz.  # INI with as many tricky parts as possible
�encodingzutf-8)r�rr�)r�)
r*�parse_errorr/�ParsingErrorrfr�MissingSectionHeaderErrorrLr^rr�findfile�open)rr-�e�tricky�error�expected�frrr	�test_parse_errors	s0						zBasicTestCase.test_parse_errorsc	CsSt|d�r|}ntj|�}|j|��}|j|�WdQX|jS)N�readline)�hasattr�io�StringIOrS�	read_filer])rr-�exc�src�siordrrr	r�%s	zBasicTestCase.parse_errorcCs�|j�}|j|j�gd�|j|jd�d�|jtj��|jd�WdQX|jtj��|j	ddd�WdQX|j
|tjdd�}|j|jd�|jd�|j
|tj
dd�}|j|jd�dS)	Nz0new ConfigParser should have no defined sectionsr�z5new ConfigParser should have no acknowledged sectionsr8�barr>)�foo)r�r�)r*rLrKrZZhas_sectionrSr/rTr�r��	get_errorr^r�rU)rr-r�rrr	�test_query_errors.s
zBasicTestCase.test_query_errorscCsay|j||�Wn)|k
r?}z	|SWYdd}~XnX|jd|j|jf�dS)Nzexpected exception type %s.%s)rPZfailrr)rr-r�r:rpr�rrr	r�?s	zBasicTestCase.get_errorcCs�|jdjd|jd��}xntdd�D]]}|j|jdd|��|j|jdd|��|jt|jdd	|�q2WdS)
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 MORE�equalsrr�ZBOOLTESTzt%dzf%dze%d)	r.rfr�rangerYrRrZrSr_)rr-�xrrr	�test_booleanHs		zBasicTestCase.test_booleancCsn|j�}|jd�|jtj��}|jd�WdQX|j}|jt|�d�|j|jd�|j	rj|jtj��6}|j
tjdj
d|jd��dd�WdQX|j}|jt|�d�|j|jd�|jtj��)}|jiid
d6dd
6d6�WdQX|j}|jt|�d�|j|jd�ndS)Nr�zSection 'Foo' already existsz�                    [Foo]
                    will this be added{equals}True
                    [Bar]
                    what about this{equals}True
                    [Foo]
                    oops{equals}this won't
                r�r�source�	<foo-bar>zFWhile reading from '<foo-bar>' [line  5]: section 'Foo' already existsr��valr�zis really `opt`�OPTr�zIWhile reading from '<dict>': option 'opt' in section 'Bar' already exists�<dict>)�FooNN)r�r�r�)zBarzoptr�N)r*r�rSr/rjr]rL�strr^r$r+rhrirfrrgrr)rr-rdr�rrr	�test_weird_errorsas&
		)	(	zBasicTestCase.test_weird_errorscCs�dj|jd|jdd|j�}|jr>|d7}n|j|�}x�d
D]�}tj�}|j|d|�|jd}|r�d	j|�}nd
jd|d|j�}|jr�|d7}n|j	|j
�|�qTWdS)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
Zcommentrr%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�z"[Valueless]
option-without-value

)TF)rfrr r%rr.r�r��writerL�getvalue)rrkr-r��outputZ	delimiterZ
expect_stringrrr	�
test_write�s(	


	
	
zBasicTestCase.test_writecCs�|jdjd|jd��}Gdd�dt�}|jddd�|jdd|d��|jdd	d�|jdd	|d��|jddd�|jdd	d�dS)
Nz[sect]
option1{eq}foo
rcrc@seZdZdS)z2BasicTestCase.test_set_string_types.<locals>.mystrN)rrrrrrr	�mystr�sr��sect�option1Zsplat�option2)r.rfrr�r�)rr-r�rrr	�test_set_string_types�sz#BasicTestCase.test_set_string_typescCs)|jddkr#|jd�ntjd�}|j�}|j|dg�}|j||g�|j|jdd�d�|j�}|j|�}|j||g�|j|jdd�d�|j�}|jdg�}|j|g�|j�}|jg�}|j|g�dS)	Nrrzincompatible formatzcfgparser.1znonexistent-filezFoo Barr8�newbar)rZskipTestrr�r*�readrLrP)rZfile1r-�parsed_filesrrr	�test_read_returns_file_list�s"z)BasicTestCase.test_read_returns_file_listcCs |jdjd|jd��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.rfr)rrrr	�get_interpolation_config�s	z&BasicTestCase.get_interpolation_configc	Cs�|jdj|j�didd6�}t|jddidd6��}|j�|j||�|jtj	��|jd�WdQXdS)	Nz�
            [section]
            name {0[0]} %(value)s
            key{0[1]} |%(name)s|
            getdefault{0[1]} |%(default)s|
        rz	<default>�defaultr:rCr>zno such section)
r.rfrrMrrJrLrSr/rT)rr�r-rbrrr	�check_items_config�s""
z BasicTestCase.check_items_configcCs�|jdj|j�didd6�}|j|j�dd�|j|j�dd�|j|j�dd�|jt��|j�WdQXdS)	Nz�
            [section1]
            name1 {0[0]} value1
            [section2]
            name2 {0[0]} value2
            [section3]
            name3 {0[0]} value3
        rz	<default>r�r�section1�section2�section3)r.rfrrL�popitemrSrX)rr-rrr	�test_popitems"zBasicTestCase.test_popitemcCs�|jidd6�}|j|j|jd�dd�idd6dd6|d	<|j|j�d	g�|jt|d	j��dddh�|j�|jt|j��t��|jt||jj��dh�dS)
Nr�r8r�z@could not locate option, expecting case-insensitive option names�value1r�ror�Zzing)r*rLrPr%rKr�r
�clear)rr-rrr	�
test_clears)
zBasicTestCase.test_clearcCs�|jdj|j�didd6�}|jt|dj��ddh�|jt|dj��d	dh�|jt|d
j��ddh�|j|ddd�|j|dd	d
�|j|d
dd�|j|j�ddd
g�idd6|d<|jt|dj��ddh�|j|ddd�|jd	|d�|j|j�ddd
g�i|d
<|jt|d
j��dh�|jd|d
�|j|j�ddd
g�i||j<|jt||jj��t��|jt|dj��dh�|jt|dj��dh�|jt|d
j��t��|j|j�ddd
g�dS)Nz�
            [section1]
            name1 {0[0]} value1
            [section2]
            name2 {0[0]} value2
            [section3]
            name3 {0[0]} value3
        rZvalueDZnameDr�Zname1Znamedr�Zname2r�Zname3r�roZvalue3Zvalue22Zname22)	r.rfrrLr�r
rKZassertNotInr%)rr-rrr	�test_setitems0"&&&&
#
&###zBasicTestCase.test_setitemN)rrrrerlrtr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrr	r2Cs(�AI*(
		6
r2c@seZdZejZdZdS)�StrictTestCaseTN)rrrr/�RawConfigParserr(r$rrrr	r�@s	r�c@smeZdZejZdd�Zdd�Zdd�Zdd�Z	d	d
�Z
dd�Zd
d�ZdS)�ConfigParserTestCasecCs�|j�}|j}||jdd�d�||jdd�d�||jdd�d�|j|tjdd�}|jtjkr�|j|jd
�n+t	|jtj
�r�|j|jd�ndS)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�5something %(with11)s lots of interpolation (11 steps))r��Foor�)r�r�r�)r�rLrPr�r/�InterpolationDepthErrorr&r1r^�
isinstance�LegacyInterpolation)rr-rcr�rrr	�test_interpolationHs	
z'ConfigParserTestCase.test_interpolationcCs�|j�}|j|tjdd�}|j|jd�|j|jd�|j|jd�|jtj	kr�|j|j
d�n+t|jtj�r�|j|j
d�ndS)N�Interpolation ErrorrO�	reference�
%(reference)s)�namer�r��	reference)r�r�r�r�)
r�r�r/�InterpolationMissingOptionErrorrLr�r:rpr&r1r^r�r�)rr-r�rrr	� test_interpolation_missing_valueXs
z5ConfigParserTestCase.test_interpolation_missing_valuecCs |jd	d
ddd
g�dS)Nr��	<default>�
getdefault�|<default>|rn�|value|rOr>)zdefaultr�)r�r�)zkeyr�)zname�value)r�r�)r�)rrrr	�
test_itemsfs
	zConfigParserTestCase.test_itemsc
Cs�|jdjd|jd��}|j|jdd�d�|jtjkro|j|jdd�d�n>t|jtj	�r�|j
t��|jdd�WdQXndS)	Nzc[section]
option1{eq}xxx
option2{eq}%(option1)s/xxx
ok{eq}%(option1)s/%%s
not_ok{eq}%(option2)s/%%srcrr:�okzxxx/%sZnot_okz
xxx/xxx/%s)r.rfrrLrPr&r/r1r�r�rS�	TypeError)rr-rrr	�test_safe_interpolationmsz,ConfigParserTestCase.test_safe_interpolationcCs�|jdjd|jd��}|j|jdd�d�|jt|jddd�|jt|jddd�|jt|jddd	�|j|jdd�d�|jdd
d�|j|jdd
�d�dS)
Nz[sect]
option1{eq}foo
rcrr�r�r8z%foozfoo%zf%oor�zfoo%%barzfoo%bar)r.rfrrLrPrSr_r�)rr-rrr	�#test_set_malformatted_interpolation|sz8ConfigParserTestCase.test_set_malformatted_interpolationcCs|jdjd|jd��}|jt|jddd�|jt|jddd�|jt|jddt��|jt|jddd�|jt|jddd�|jt|jddt��|jt|jdd	d
�|jt|jd	�dS)Nz[sect]
option1{eq}foo
rcrr�r�rg�?r�rmzinvalid opt name!)r.rfrrSr�r��objectr�)rr-rrr	�test_set_nonstring_types�sz-ConfigParserTestCase.test_set_nonstring_typescCs)|j�}|jt|j|j�dS)N)r*rSr_r�r%)rr-rrr	�test_add_section_default�sz-ConfigParserTestCase.test_add_section_defaultN)
rrrr/�ConfigParserr(r�r�r�r�r�r�r�rrrr	r�Es	r�c@sdeZdZejZdZejd�j	�Z
dd�Zdd�Zdd�Z
d	d
�ZdS)�#ConfigParserTestCaseNoInterpolationNz�
        [numbers]
        one = 1
        two = %(one)s * 2
        three = ${common:one} * 3

        [hexen]
        sixteen = ${numbers:two} * 8
    cCsd|j|ddd�|j|ddd�|j|ddd�|j|dd	d
�dS)NZnumbersZonerFZtwoz%(one)s * 2Zthreez${common:one} * 3ZhexenZsixteenz${numbers:two} * 8)rL)rr-rrr	�assertMatchesIni�sz4ConfigParserTestCaseNoInterpolation.assertMatchesInicCs#|j|j�}|j|�dS)N)r.�inir�)rr-rrr	�test_no_interpolation�sz9ConfigParserTestCaseNoInterpolation.test_no_interpolationcCs&|j�}|j|jd��dS)N�)r*ZassertIsNoner+)rr-rrr	�test_empty_case�sz3ConfigParserTestCaseNoInterpolation.test_empty_casecCsCGdd�dtj�}|�}|j|j�|j|�dS)Nc@seZdZdZdS)zbConfigParserTestCaseNoInterpolation.test_none_as_default_interpolation.<locals>.CustomConfigParserN)rrrZ_DEFAULT_INTERPOLATIONrrrr	�CustomConfigParser�sr�)r/r�r+r�r�)rr�r-rrr	�"test_none_as_default_interpolation�s	zFConfigParserTestCaseNoInterpolation.test_none_as_default_interpolation)rrrr/r�r(r&rhri�stripr�r�r�r�r�rrrr	r��s	r�c@s1eZdZejZej�Zdd�ZdS)�'ConfigParserTestCaseLegacyInterpolationcCs�|jdjd|jd��}|j|jdd�d�|jddd�|j|jdd�d�|jddd�|j|jdd�d�|jddd	�|j|jdd�d	�|jdd
d�|j|jdd
�d�dS)Nz[sect]
option1{eq}foo
rcrr�r�r8z%foozfoo%zf%oor�zfoo%%bar)r.rfrrLrPr�)rr-rrr	r��szKConfigParserTestCaseLegacyInterpolation.test_set_malformatted_interpolationN)	rrrr/r�r(r�r&r�rrrr	r��s	r�c@s"eZdZdZdZdZdS)	�)ConfigParserTestCaseNonStandardDelimiters�:=�$�//�"N)r�r�)r�r�)r�r�)rrrrr r!rrrr	r��sr�c@seZdZdZdS)�-ConfigParserTestCaseNonStandardDefaultSectionZgeneralN)rrrr%rrrr	r��sr�c@sOeZdZejZdjdd�Zdd�Zdd�Z	dd	�Z
d
S)�MultilineValuesTestCasezSI'm having spam spam spam spam spam spam spam beaked beans spam spam spam and spam!� z	
c	Cs�|j�}xftd�D]X}dj|�}|j|�x3td�D]%}|j|dj|�|j�qHWqWttjd��}|j	|�WdQXdS)N�dz	section{}�
z
lovely_spam{}�w)
r*r�rfr�r��wonderful_spamr�r�TESTFNr�)rr-r
�s�jr�rrr	�setUp�s
'zMultilineValuesTestCase.setUpcCstjtj�dS)N)�os�unlinkrr)rrrr	�tearDown�sz MultilineValuesTestCase.tearDowncCs`|j�}ttj��}|j|�WdQX|j|jdd�|jjdd��dS)NZsection8Zlovely_spam4z	
�
)	r*r�rrr�rLrPr�replace)rZcf_from_filer�rrr	� test_dominating_multiline_values�s
z8MultilineValuesTestCase.test_dominating_multiline_valuesN)rrrr/r�r(r
rrrrrrrr	r��s	
r�c@s=eZdZejZdd�Zdd�Zdd�ZdS)�RawConfigParserTestCasecCs}|j�}|j}||jdd�d�||jdd�d�||jdd�d�||jdd�d	�dS)
Nr�r�z*something %(with1)s interpolation (1 step)r�z3something %(with9)s lots of interpolation (9 steps)r�z5something %(with10)s lots of interpolation (10 steps)r�z5something %(with11)s lots of interpolation (11 steps))r�rLrP)rr-rcrrr	r��s	z*RawConfigParserTestCase.test_interpolationcCs |jd
ddd
dg�dS)Nr��	<default>r��
|%(default)s|rn�
|%(name)s|rO�	%(value)sr>)zdefaultr)z
getdefaultr)zkeyr)znamer)�valuer)r�)rrrr	r�s
	z"RawConfigParserTestCase.test_itemscCsw|j�}|jd�|jddd�|jddddddddd	d
g�|jddidd
6�|j|jdd�d�|j|jdd�ddddddd	d
g�|j|jdd�idd
6�|jd�|jddd�|j|jdd�d�|jtjkrsdd�|_|jddd�|j|jdd�d�ndS)Nz
non-stringr?rrMr��r���
r'gn��!	@Zpirmzthis is sickTcSs|S)Nr)r�rrr	�<lambda>"szBRawConfigParserTestCase.test_set_nonstring_types.<locals>.<lambda>)	r*r�r�rLrPZ_dictr/r0�optionxform)rr-rrr	r�s 
+#
z0RawConfigParserTestCase.test_set_nonstring_typesN)	rrrr/r�r(r�r�r�rrrr	r�s	rc@s"eZdZdZdZdZdS)	�,RawConfigParserTestCaseNonStandardDelimiters�:=r��//r�N)rr�)rr�)rr�)rrrrr r!rrrr	r&src@s7eZdZejZd	Zd
ZdZdd�Z	dS)�RawConfigParserTestSambaConfrr�----�//FcCs�tjd�}|j�}|j|dgdd�}|j||g�ddddd	d
dg}|j|j�|�|j|jdd�d
�|j|jdd�d�|j|jdd�d�|j|jd
d�d�dS)Nzcfgparser.2znonexistent-filer�zutf-8�globalZhomesZprinterszprint$z
pdf-generatorZtmpZAgustinZ	workgroupZMDKGROUPzmax log size�2zhosts allowz127.zecho commandz
cat %s; rm %s)rr�r*r�rLrKrPrQ)rZsmbconfr-r�rKrrr	�test_reading1s	z)RawConfigParserTestSambaConf.test_readingN)rrr)r )
rrrr/r�r(r r!r"r#rrrr	r+s
	rc@s�eZdZejZej�ZdZdZ	dddd�Z
dd�Zdd	�Zd
d�Z
dd
�Zdd�Zdd�ZdS)�)ConfigParserTestCaseExtendedInterpolation�commonTNcCs2|j|�}|r!||_n|j|�|S)N)r*rr+)rr,rrr-rrr	r.Es

z4ConfigParserTestCaseExtendedInterpolation.fromstringcCs�|jtjd�j��}|j}||ddd�||ddd�||ddd�||ddd�||ddd	�||dd
d�||ddd
�||ddd�||ddd�||ddd�||ddd�||ddd�||ddd�||ddd�||ddd�||dd
d�||ddd�dS)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%zfavourite BeatleZPaulzfavourite colorZgreenZtomzfavourite bandz	green dayzfavourite popezJohn Paul IIZsequelz
John Paul IIIZambvZGeorgezson of Edward VIIzGeorge Vzson of George Vz	George VIZstanleyZblackzfavourite state of mindZparanoidzfavourite moviez
soylent greenzfavourite songzblack sabbath - paranoid)r.rhrir�rL)rr-rcrrr	�test_extended_interpolationLs*	zEConfigParserTestCaseExtendedInterpolation.test_extended_interpolationcCsl|jtjd�j��}|jtj��|ddWdQX|jtj��|ddWdQXdS)Nz�
            [one for you]
            ping = ${one for me:pong}

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

            [selfish]
            me = ${me}
        zone for youZpingZselfish�me)r.rhrir�rSr/r�)rr-rrr	�test_endless_loopys	z;ConfigParserTestCaseExtendedInterpolation.test_endless_loopc	Cs�|jd�}|j|ddd�|j|ddd�|j|ddd�tj}|j|��}|dd	WdQX|j|jjd
�|j|jjdd�dS)
Nz�
            [dollars]
            $var = $$value
            $var2 = ${$var}
            ${sick} = cannot interpolate me

            [interpolated]
            $other = ${dollars:$var}
            $trying = ${dollars:${sick}}
        Zdollarsz$varz$valueZinterpolatedz$otherz${sick}zcannot interpolate mez$tryingzdollars:${sickrz${dollars:${sick}})r.rLr/r�rSr]r�r^)rr-Zexception_classrdrrr	�test_strange_options�s			z>ConfigParserTestCaseExtendedInterpolation.test_strange_optionscCs�tjd�j�}|j|�}|j}||ddd�||ddd�||ddd�||ddd	�||d
dd�||d
d
d�dS)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%Zoptionlowerr>ZOptionUpper�Value�Commonza better valuezA Better Value�randomZfoolowerzvalue redefinedZFooUpperzA Better Value Redefined)rhrir�r.rL)rr�r-rcrrr	�test_case_sensitivity_basic�s	zEConfigParserTestCaseExtendedInterpolation.test_case_sensitivity_basiccCs�tjd�j�}|jtj��|j|�}WdQX|j|ddd��}|j}||ddd�||ddd	�||d
dd�||d
dd�||d
dd�||d
dd�dS)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
        rcSs|S)Nr)r�rrr	r�sz[ConfigParserTestCaseExtendedInterpolation.test_case_sensitivity_conflicts.<locals>.<lambda>r%rpr>r~r*r+za better valuezA Better Valuer,r8zvalue redefinedr�zA Better Value Redefined)rhrir�rSr/rgr.rL)rr�r-rcrrr	�test_case_sensitivity_conflicts�s	zIConfigParserTestCaseExtendedInterpolation.test_case_sensitivity_conflictsc(Cs�|jd�}|jtj��|ddWdQX|jtj��|ddWdQX|jtj��|ddWdQX|jtj��|ddWdQX|jtj��|ddWdQX|jt��d|dd	<WdQXdS)
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!
        zinterpolation failZcase1Zcase2Zcase3Zcase4Zcase5z
BLACK $ABBATHZcase6)r.rSr/�InterpolationSyntaxErrorr�r_)rr-rrr	�test_other_errors�s	z;ConfigParserTestCaseExtendedInterpolation.test_other_errors)rrrr/r�r(ZExtendedInterpolationr&r%r$r.r&r(r)r-r.r0rrrr	r$?s	-r$c@seZdZdZdS)�ConfigParserTestCaseNoValueTN)rrrrrrrr	r1�sr1c@sIeZdZejZdhZdhZdZdd�Z	dd�Z
dS)	�ConfigParserTestCaseTrickyFilerrTcCs
tjd�}|j�}|jt|j|dd��d�|j|j�ddddd	d
dg�|j|j|jdd
idd6�d�|j	t
��+|j|jdddd
idd6�WdQX|jt|jdd�jd��d�|jt|jdd�jd��d�d}|j
|j|d��|j|j|d�d�|jt|jd��d�|j	tj��|jd	�WdQX|j|jd
d�d�|j|jd
d�|jd
d��|j|jdd�d�dS)Nzcfgparser.3r�zutf-8rZstrangeZ
corruptionz&yeah, sections can be indented as wellzanother one!zno values hereztricky interpolationzmore interpolationZgorCz-1Zinterpolate�rawT�otherr�r>rzare they subsectionszlets use some Unicodeu	片仮名r�Zletszdo thiszgo shopping���)rr�r*rLrNr�rKrQr%rSr_rP�splitrZrRrr/r�)rr�r-Zlongnamerrr	�test_cfgparser_dot_3�s6%
++z3ConfigParserTestCaseTrickyFile.test_cfgparser_dot_3cCsHtjd�}|j�}|jt��|j|dd�WdQXdS)Nzcfgparser.3r��ascii)rr�r*rS�UnicodeDecodeErrorr�)rr�r-rrr	�test_unicode_failuresz3ConfigParserTestCaseTrickyFile.test_unicode_failureN)rrrr/r�r(rr rr8r;rrrr	r2�s			 r2c@s@eZdZdZdZdd�Zdd�Zdd�Zd	S)
�Issue7005TestCasezrTest output when None is set() as a value and allow_no_value == False.

    http://bugs.python.org/issue7005

    z[section]
option = None

cCsR|dd�}|jd�|jddd�tj�}|j|�|j�S)NrFr:rp)r�r�r�r�r�r�)rr(�cpr�rrr	�prepare#s

zIssue7005TestCase.preparecCsLtjdd�}|jd�|jt��|jddd�WdQXdS)NrFr:rp)r/r�r�rSr�r�)rr=rrr	�test_none_as_value_stringified,s
z0Issue7005TestCase.test_none_as_value_stringifiedcCs)|jtj�}|j||j�dS)N)r>r/r�rL�expected_output)rr�rrr	�"test_none_as_value_stringified_raw2sz4Issue7005TestCase.test_none_as_value_stringified_rawN)rrr�__doc__r@r>r?rArrrr	r<s
	r<c@s"eZdZeZdd�ZdS)�SortedTestCasecCsB|jd�}tj�}|j|�|j|j�d�dS)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�rLr�)rr-r�rrr	�test_sorted:s

zSortedTestCase.test_sortedN)rrrrr#rDrrrr	rC7srCc@s1eZdZejZdZdZdd�ZdS)�CompatibleTestCasez#;rcCsvtjd�}|j|�}|j|jdd�d�|j|jdd�d�|j|jdd�d�dS)	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
        z
Commented Barr8zbar # not a comment!r6r7Zquirkzthis;is not a comment)rhrir.rLrP)rrkr-rrr	�test_comment_handlingSs	z(CompatibleTestCase.test_comment_handlingN)	rrrr/r�r(r r!rFrrrr	rENs	rEc@s(eZdZejZddd�ZdS)�CopyTestCaseNcCs�|j|�}|j|�|j�}|j|�xj|j�D]\}|j|jkr`qBnx;||jj�D]&\}}|||krt||=qtqtWqBW|S)N)r*r+rrrrOr%r)rr,rr-Zcf_copyr:r�r>rrr	r.gs

 zCopyTestCase.fromstring)rrrr/r�r(r.rrrr	rGds	rGc@s(eZdZdd�Zdd�ZdS)�FakeFilec	CsDtjd�}t|��#}|j�|_|jj�WdQXdS)Nzcfgparser.1)rr�r��	readlines�lines�reverse)r�	file_pathr�rrr	�__init__xszFakeFile.__init__cCs t|j�r|jj�SdS)Nr�)rNrJ�pop)rrrr	r�~s
zFakeFile.readlineN)rrrrMr�rrrr	rHwsrHccs.|j�}x|r)|V|j�}qWdS)z+As advised in Doc/library/configparser.rst.N)r�)r��linerrr	�readline_generator�s	rPc@s@eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�ReadFileTestCasecCs�tjd�g}y|j|djd��Wntk
rDYnXxx|D]p}tj�}t|��}|j|�WdQX|j	d|�|j	d|d�|j
|ddd�qLWdS)Nzcfgparser.1r�utf8zFoo Barr8r�)rr�rI�encode�UnicodeEncodeErrorr/r�r�r��assertInrL)rZ
file_pathsrLrVr�rrr	�	test_file�s

zReadFileTestCase.test_filecCswtjd�j�jd�}tj�}|j|�|jd|�|jd|d�|j|ddd�dS)Nz%
        [Foo Bar]
        foo=newbarrzFoo Barr8r�)	rhrir�r7r/r�r�rUrL)rrJrVrrr	�
test_iterable�s
zReadFileTestCase.test_iterablec
Cs�tj�}|jt��|jt��WdQX|jtt���|jd|�|jd|d�|j|ddd�dS)z
Issue #11670.NzFoo Barr8r�)	r/r�rSr�r�rHrPrUrL)rrVrrr	�test_readline_generator�sz(ReadFileTestCase.test_readline_generatorcCs�tjd�j�jd�}tj�}|jtj��}|j|dd�WdQX|j	t
|j�d�tjd�j�jd�}tj�}|jtj��}|j|dd�WdQX|j	t
|j�d�tjd	�j�jd�}tj�}|jtj
��}|j|dd�WdQX|j	t
|j�d
�tjd�j�jd�}tj�}|jtj��}|j|dd�WdQX|j	t
|j�d�dS)
z
Issue #18260.z"
        [badbad]
        [badbad]rr�sbadbadNzGWhile 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')rhrir�r7r/r�rSrjr�rLr�r]rgr�r�)rrJrVZdserrr	�test_source_as_bytes�s@z%ReadFileTestCase.test_source_as_bytesN)rrrrVrWrXrYrrrr	rQ�s

rQc@sjeZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dS)�CoverageOneHundredTestCasez"Covers edge cases in the codebase.cCs�tjdd�}|j|jd�|j|jd�|j|jd�|j|jd�|j|jd�|jt|�d�dS)Nr:rpz3Option 'option' in section 'section' already exists)zsectionzoptionNN)	r/rgrLr:rpr��linenor^r�)rr�rrr	�test_duplicate_option_error�sz6CoverageOneHundredTestCase.test_duplicate_option_errorcCsRtjddd�}|j|jd�|j|jd�|j|jd�dS)Nrpr:�rawval)zoptionzsectionr])r/r�rLr^rpr:)rr�rrr	�test_interpolation_depth_error�s
	z9CoverageOneHundredTestCase.test_interpolation_depth_errorcCs,|jt��}tj�WdQX|jt|j�d�|jt��}tjdddd�WdQX|jt|j�d�tjdd�}|j|jd�tj	dd��F}tj
dt�|j|jd�d|_|j|jd�WdQXx$|D]}|j
|jtk�qWdS)Nz%Required argument `source' not given.r��filenamez:Cannot specify both `filename' and `source'. Use `source'.�recordT�always)rSr_r/r�rLr�r]r��warnings�catch_warnings�simplefilter�DeprecationWarningr_rY�category)rrdr�r�warningrrr	�test_parsing_error�s	
z-CoverageOneHundredTestCase.test_parsing_errorcCs�tj�}|jd�|jtj��}|ddWdQX|jt|j�d�|jtj��}|ddWdQX|jt|j�d�dS)Nz�
            [section]
            invalid_percent = %
            invalid_reference = %(()
            invalid_variable = %(does_not_exist)s
        r:Zinvalid_percentz.'%' must be followed by '%' or '(', found: '%'Zinvalid_referencez+bad interpolation variable reference '%(()')r/r�r+rSr/rLr�r])rrVrdrrr	�test_interpolation_validationsz8CoverageOneHundredTestCase.test_interpolation_validationcCs�tjd�}tj�}tjdd��*}tjdt�|j|dd�WdQXx$|D]}|j	|j
tk�q`W|jt|�d�|j|dd	d
�dS)Nz2
        [section]
        option = value
        r`Trar_r�rr:rpr>)
r�r�r/r�rbrcrdreZreadfprYrfrLrN)rr�rVrrgrrr	�test_readfp_deprecations	
z2CoverageOneHundredTestCase.test_readfp_deprecationc
Csbtjdd��#}tjdt�tj�}WdQXx$|D]}|j|jtk�q>WdS)Nr`Tra)rbrcrdrer/ZSafeConfigParserrYrf)rrrVrgrrr	�!test_safeconfigparser_deprecation%s

z<CoverageOneHundredTestCase.test_safeconfigparser_deprecationcCs7tj�}|jd�|jt|d�d�dS)Nz7
            [section]
            key = value
        r:z<Section: section>)r/r�r+rL�repr)rrVrrr	�test_sectionproxy_repr,sz1CoverageOneHundredTestCase.test_sectionproxy_reprN)rrrrBr\r^rhrirjrkrmrrrr	rZ�s
rZc@s�eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dd�ZdS)�ExceptionPicklingTestCasezBTests for issue #13760: ConfigParser exceptions are not picklable.cCs�ddl}tjd�}xnt|jd�D]Y}|j||�}|j|�}|j|j|j�|jt	|�t	|��q/WdS)Nrr>r)
�pickler/�Errorr��HIGHEST_PROTOCOL�dumps�loadsrL�messagerl)rro�e1�proto�pickled�e2rrr	�
test_error8sz$ExceptionPicklingTestCase.test_errorcCs�ddl}tjd�}x�t|jd�D]�}|j||�}|j|�}|j|j|j�|j|j	|j	�|j|j
|j
�|jt|�t|��q/WdS)Nrr:r)ror/rTr�rqrrrsrLrtr^r:rl)rrorurvrwrxrrr	�test_nosectionerrorAsz-ExceptionPicklingTestCase.test_nosectionerrorcCs�ddl}tjdd�}x�t|jd�D]�}|j||�}|j|�}|j|j|j�|j|j	|j	�|j|j
|j
�|j|j|j�|jt|�t|��q2WdS)Nrrpr:r)
ror/rUr�rqrrrsrLrtr^r:rprl)rrorurvrwrxrrr	�test_nooptionerrorLsz,ExceptionPicklingTestCase.test_nooptionerrorcCs�ddl}tjddd�}x�t|jd�D]�}|j||�}|j|�}|j|j|j�|j|j	|j	�|j|j
|j
�|j|j|j�|j|j|j�|jt
|�t
|��q5WdS)Nrr:r�rmr)ror/rjr�rqrrrsrLrtr^r:r�r[rl)rrorurvrwrxrrr	�test_duplicatesectionerrorXsz4ExceptionPicklingTestCase.test_duplicatesectionerrorcCsddl}tjdddd�}x�t|jd�D]�}|j||�}|j|�}|j|j|j�|j|j	|j	�|j|j
|j
�|j|j|j�|j|j|j�|j|j
|j
�|jt|�t|��q8WdS)Nrr:rpr�rmr)ror/rgr�rqrrrsrLrtr^r:rpr�r[rl)rrorurvrwrxrrr	�test_duplicateoptionerrores	z3ExceptionPicklingTestCase.test_duplicateoptionerrorcCs�ddl}tjddd�}x�t|jd�D]�}|j||�}|j|�}|j|j|j�|j|j	|j	�|j|j
|j
�|j|j|j�|jt|�t|��q5WdS)Nrrpr:�msgr)
ror/ZInterpolationErrorr�rqrrrsrLrtr^r:rprl)rrorurvrwrxrrr	�test_interpolationerrortsz1ExceptionPicklingTestCase.test_interpolationerrorcCs�ddl}tjdddd�}x�t|jd�D]�}|j||�}|j|�}|j|j|j�|j|j	|j	�|j|j
|j
�|j|j|j�|j|j|j�|jt
|�t
|��q8WdS)Nrrpr:r]r�r)ror/r�r�rqrrrsrLrtr^r:rpr�rl)rrorurvrwrxrrr	�$test_interpolationmissingoptionerror�sz>ExceptionPicklingTestCase.test_interpolationmissingoptionerrorcCs�ddl}tjddd�}x�t|jd�D]�}|j||�}|j|�}|j|j|j�|j|j	|j	�|j|j
|j
�|j|j|j�|jt|�t|��q5WdS)Nrrpr:r~r)
ror/r/r�rqrrrsrLrtr^r:rprl)rrorurvrwrxrrr	�test_interpolationsyntaxerror�sz7ExceptionPicklingTestCase.test_interpolationsyntaxerrorcCs�ddl}tjddd�}x�t|jd�D]�}|j||�}|j|�}|j|j|j�|j|j	|j	�|j|j
|j
�|j|j|j�|jt|�t|��q5WdS)Nrrpr:r]r)
ror/r�r�rqrrrsrLrtr^r:rprl)rrorurvrwrxrrr	�test_interpolationdeptherror�s	z6ExceptionPicklingTestCase.test_interpolationdeptherrorcCs�ddl}tjd�}|jdd�|jdd�|jdd�x�t|jd�D]�}|j||�}|j|�}|j|j	|j	�|j|j
|j
�|j|j|j�|j|j|j�|jt
|�t
|��q_Wtjd	d	�}|jdd�|jdd�|jdd�x�t|jd�D]�}|j||�}|j|�}|j|j	|j	�|j|j
|j
�|j|j|j�|j|j|j�|jt
|�t
|��qTWdS)
Nrr�rZline1rZline2rZline3r_)ror/r�rIr�rqrrrsrLrtr^r��errorsrl)rrorurvrwrxrrr	�test_parsingerror�s2 z+ExceptionPicklingTestCase.test_parsingerrorcCs�ddl}tjddd�}x�t|jd�D]�}|j||�}|j|�}|j|j|j�|j|j	|j	�|j|j
|j
�|j|j|j�|j|j|j�|jt
|�t
|��q5WdS)Nrr_rmrOr)ror/r�r�rqrrrsrLrtr^rOr�r[rl)rrorurvrwrxrrr	�test_missingsectionheadererror�sz8ExceptionPicklingTestCase.test_missingsectionheadererrorN)rrrrBryrzr{r|r}rr�r�r�r�r�rrrr	rn5s	

rnc@s"eZdZdZdd�ZdS)�InlineCommentStrippingTestCasez}Tests for issue #14590: ConfigParser doesn't strip inline comment when
    delimiter occurs earlier without preceding space..cCs�tjdd�}|jd�|d}|j|dd�|j|d	d
�|j|dd�|j|d
d�|j|dd�|j|dd�|j|dd�|d}|j|dd�|j|d	d
�|j|dd�dS)Nr!rr�//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:Zk1zv1;still v1Zk2Zv2Zk3Zv3Zk4zv4;still v4Zk5zv5;still v5Zk6zv6;still v6; and still v6Zk7zv7;still v7; and still v7Zmultiprefixzv3;#//still v3# and still v3)rrr�)r/r�r+rL)rZcfgrrrr	�test_stripping�s 		

z-InlineCommentStrippingTestCase.test_strippingN)rrrrBr�rrrr	r��sr��__main__)(�collectionsr/r�r	�sysrhZunittestrbZtestr�UserDictrrr2ZTestCaser�r�r�r�r�r�r�rrrr$r1r2r<rCrErGrHrPrQrZrnr�r�mainrrrr	�<module>sN ���Z$*�-
SV�$