Sindbad~EG File Manager

Current Path : /usr/local/lib/python3.9/test/__pycache__/
Upload File :
Current File : //usr/local/lib/python3.9/test/__pycache__/test_configparser.cpython-39.pyc

a

��g�S�@stddlZddlZddlZddlZddlZddlZddlZddlZddlm	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%Gd7d8�d8ej�Z&Gd9d:�d:e
ej�Z'Gd;d<�d<ej�Z(Gd=d>�d>ej�Z)e*d?k�rpe�+�dS)@�N)�supportc@s@eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�ZeZ	d
S)�
SortedDictcCst|j���S�N)�sorted�data�items��self�r
�2/usr/local/lib/python3.9/test/test_configparser.pyrszSortedDict.itemscCst|j���Sr)rr�keysrr
r
rrszSortedDict.keyscCsdd�|��D�S)NcSsg|]}|d�qS)�r
)�.0�ir
r
r�
<listcomp>�z%SortedDict.values.<locals>.<listcomp>)rrr
r
r�valuesszSortedDict.valuescCst|���Sr)�iterrrr
r
r�	iteritemsszSortedDict.iteritemscCst|���Sr)rrrr
r
r�iterkeysszSortedDict.iterkeyscCst|���Sr)rrrr
r
r�
itervaluesszSortedDict.itervaluesN)
�__name__�
__module__�__qualname__rrrrrr�__iter__r
r
r
rr
src@sJeZdZdZdZdZdZdZej	Z
dZejZ
ejZd
dd�Zddd	�ZdS)�CfgParserTestCaseClassF)�=�:)�;�#TNcCsBt||j|j|j|j|j|j|j|j|j	d�
}|j
fi|��}|S)N)
�defaults�allow_no_value�
delimiters�comment_prefixes�inline_comment_prefixes�empty_lines_in_values�	dict_type�strict�default_section�
interpolation)�dictr!r"r#r$r%r&r'r(r)�config_class)r	r Z	arguments�instancer
r
r�	newconfig/s�z CfgParserTestCaseClass.newconfigcCs|�|�}|�|�|Sr)r-�read_string)r	�stringr �cfr
r
r�
fromstring?s

z!CfgParserTestCaseClass.fromstring)N)N)rrrr!r"r#r$r%�configparser�
_default_dictr&r'ZDEFAULTSECTr(�_UNSETr)r-r1r
r
r
rr$s
rc@s�eZdZdd�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)d*�Zd+d,�Zd-S).�
BasicTestCasec	Cs
gd�}|jr|�d�|��ddg}|��}|��|j}|||�|�d�}|��|||�dd�|D�}|��|�|j�|��|||�|d��}tt|��}|||�|��}tt|��}|�t	|�t	|��|D]\}}|||j
�q�||��||j�||�dd	�d
�||�dd	�d�||�dd	�d
�||�dd�d�||�dd	�d�||�dd�d�||�dd�d�||�dd�d�||�
dd�d�||�dd�d�|�|�dd�d�||�dd�d�||�dd�d�||�dd �d!�|j�r(||�dd"�d�||jdd	dd#�d
�||jdd	d	did$�d�|�tj��|�d%d	�Wd�n1�s�0Y|�tj��|�dd&�Wd�n1�s�0Y||jd%d	dd#�d�||jdd&dd#�d�||jdd	dd#�d�||jd'd	dd#�d�||j
ddd(d#�d�||j
dd)d(d#�d(�||j
dd)d*d#�d*�|�tj��|�
dd)�Wd�n1�s�0Y|�|jddd+d#�d�|�|jdd,d+d#�d+�||jdd,d-d#�d-�|�tj��|�dd,�Wd�n1�s0Y||jddd.d#�d�||jdd/d0d#�d0�||jdd/d.d#�d.�|�tj��|�dd/�Wd�n1�s�0Y||jd1dd.d#�d.�|j�r�||jdd"dd#�d�||jdd2dd#�d�||dd	d
�||dd	d�|d}||j
d�|�|j|�|�t��d3|_
Wd�n1�sT0Y|�t��d4|_Wd�n1�s�0Y||d	d
�||dd�||dd	d�||ddd�||ddd�||ddd�||d5d	d6�|j�r ||dd"d�||d�d	d�d
�||djd	dd#�d
�||djd	d	did$�d�|�t��|d%d	Wd�n1�s�0Y|�t��|dd&Wd�n1�s�0Y|�t��"|d%jd	dd#�Wd�n1�s0Y||d�d&d�d�||djd&dd#�d�||d�d&�d�||d�d	d�d�||djd	dd#�d�|�t�� |d'�d	d�Wd�n1�s�0Y||d�
dd(�d�||dj
dd(d#�d�||d�
d)d(�d(�||dj
d)d(d#�d(�||d�
d)d*�d*�||dj
d)d*d#�d*�||d�
d)�d�|�|d�dd+�d�|�|djdd+d#�d�|�|d�d,d+�d+�|�|djd,d+d#�d+�||d�d,d-�d-�||djd,d-d#�d-�||d�d,�d�||d�dd.�d�||djdd.d#�d�||d�d/d0�d0�||djd/d0d#�d0�||d�d/d.�d.�||djd/d.d#�d.�||d�d/�d�|j�
r
||d�d"d�d�||djd"dd#�d�||d�d2d�d�||djd2dd#�d�d7||jd8<d9||jd:<|�|�d��|�|�dd��|�|�d��|�|�|j��|�|�dd	�d;�|�|�dd	�d<�|�|�dd	�d=�|�|�dd8��|�|�dd8��|�|�|jd8��|�|�dd8��|�|�|jd8��|�tj��}|�d>d	�Wd�n1�s40Y|�|jjd?�||�d5d	�d6�|d=|�d|v�|�t��|d=Wd�n1�s�0Y|�t ��||j=Wd�n1�s�0Y|dd	=|�d	|dv�|�t��|dd	=Wd�n1�s"0Y|�d:|dv�|�t��|dd:=Wd�n1�sj0Y||jd:=|�d:|dv�|�t��||jd:=Wd�n1�s�0Y|�t��|d>d	=Wd�n1�s�0YdS)@N)	�
Commented Bar�Foo Bar�Internationalized Stuff�	Long Line�Section\with$weird%characters[	�Spaces�
Spacey Bar�Spacey Bar From The Beginning�Types�NoValue)�baz�qwe)�foo�bar3r=cSsg|]}|�qSr
r
�r�sectionr
r
rrbrz,BasicTestCase.basic_test.<locals>.<listcomp>r7rB�bar1r<�bar2rCr@rAr6�bar4r;�key with spaces�value�another with spaces�splat!r>�int�*Z42�float�)\��(�?z0.44�booleanFZ123�strange but acceptable�option-without-value��fallback��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-onlyr9�7this 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)r])!r!�append�sort�sections�assertEqualrr(r�list�len�namer �get�getint�assertAlmostEqual�getfloat�
getboolean�assertRaisesr2�NoSectionError�
NoOptionError�assertIs�parser�AttributeError�KeyError�
assertTrueZremove_section�assertFalse�
has_option�
remove_option�	exception�args�
ValueError)	r	r0�E�F�L�eqrdrE�cmr
r
r�
basic_testGs�





,,,����,�,
��&&�,,20����������,�&(
**,zBasicTestCase.basic_testcCs�d�|j|j�}|jr|d7}|�|�}|�|�|jr�|�tj	��(|�
t�d�|j���Wd�n1sr0Y|�tj
��(|�
t�d�|j���Wd�q�1s�0Yn0|�
t�d�|j���|�
t�d�|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
            )�formatr"r#r!r1r}r'rjr2�DuplicateOptionErrorr.�textwrap�dedent�DuplicateSectionError�r	�
config_stringr0r
r
r�
test_basic%s0��

�&�(��zBasicTestCase.test_basicc
Cs>ddiddiddd�ddd�ddiid	d
ddd
�ddd�ddddd�d�	}|jrb|�dddii�|��}|�|�|�|�|j�r|�tj��(|�ddiddid��Wd�n1s�0Y|�tj	��$|�dddd �i�Wd�n1�s0Yn,|�ddiddid!��|�dddd �i�dS)"NrBrFrGrCrA)rBr@rHrZZ	BulgarianZDefaultZEnglishZDeutsch)zfoo[bg]rBzfoo[en]zfoo[de]rJrL)rIrKrNrPFrR)rMrOrQ�{)	r7r<r=r6r9r:r8r;r>r?rS�keyZkey2�value2)r[r
zDuplicate Options Herezwith a valuezwith another value)�optionZOPTION)rEZSECTION)
r!�updater-�	read_dictr}r'rjr2r�r)r	�configr0r
r
r�test_basic_from_dictfsv���������&��

�&��(���z"BasicTestCase.test_basic_from_dictcCs�|��}|�d�|�d�|�d�|��}|��|j}||gd��|�ddd�||�d�dg�||�dd�dd�|�t	j
��|�ddd�Wd�n1s�0Y|�|�dd��|�
|�dd��|�ddd	�d
D]}|�|�d|�d�q�||�d�dg�||�d�dg�|�dd�||�d�g�|�d
�|jd��}||�d�dg�||�dd�d�|jd�|jd�ddid�}|�|�dd��dS)N�A�a�B)r�r�r�rJ�b�@could not locate option, expecting case-insensitive option names�A-B�	A-B value��a-bzA-bza-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 rE�Key)r-�add_sectionr`r_ra�set�optionsrerjr2rkrqrsrrrtr1r~r")r	r0rzr{�optr
r
r�test_case_sensitivity�sP


�,
�����z#BasicTestCase.test_case_sensitivitycCs�|��}i|d<ddi|d<i|d<dd�|D�}|��|j}|j}||tdd|jdg��||d��dh�||dddd�|�t��d|dd<Wd�n1s�0Y|�	d|dv�d	|dd
<dD]}|�	||dvd�q�||d��d
h�||d��dh�|dd=||d��i�|�
d�|jd��}||d��dh�||ddd�|j
d�|jd�ddid�}|�	d|dv�dS)Nr�r�rJr�cSsg|]}|�qSr
r
rDr
r
rr�rzFBasicTestCase.test_case_sensitivity_mapping_access.<locals>.<listcomp>r�r�r�r�r�r�r�r�rr�r�r�r�r�r�r�r�rE)
r-r_raZassertCountEqualrr(rrjrprqr1r~r")r	r0rzr{Zelem_eqr�r
r
r�$test_case_sensitivity_mapping_access�sN�*
�
����z2BasicTestCase.test_case_sensitivity_mapping_accesscCsP|�ddi�}|�|�|jd�dd�|�ddi�}|�|�|jd�dd�dS)NrB�Bar�Foor�z<could not locate option, expecting case-insensitive defaults)r-rarer(�r	r0r
r
r�test_default_case_sensitivitys��z+BasicTestCase.test_default_case_sensitivitycCs|��}|�|tjd�|jd��|�|tjd�|jd��|�|tjd�}|�|jd�|j	�s|�|tjd�}|�|jd�t
�d�}|jdd	kr�tj}|f}ntj}|dd
f}t|dd��}|�|||�}Wd�n1s�0Y|�|j|�dS)
Nz[Foo]
{}val-without-opt-name
rr
�No Section!
)�<???>r
r�z[Foo]
  wrong-indent
)r��cfgparser.3rz.  # INI with as many tricky parts as possible
�utf-8��encoding)
r-�parse_errorr2�ParsingErrorr~r"�MissingSectionHeaderErrorrarvr!r�findfile�open)r	r0�e�tricky�error�expected�fr
r
r�test_parse_errorss>
��
��
�
�
�,zBasicTestCase.test_parse_errorscCsTt|d�r|}n
t�|�}|�|��}|�|�Wd�n1sD0Y|jS)N�readline)�hasattr�io�StringIOrj�	read_fileru)r	r0�exc�src�sior|r
r
rr�'s

(zBasicTestCase.parse_errorcCs�|��}|�|��gd�|�|�d�d�|�tj��|�d�Wd�n1sX0Y|�tj��|�	ddd�Wd�n1s�0Y|�
|tjdd�}|�|jd�|�d�|�
|tj
dd�}|�|jd�dS)	Nz0new ConfigParser should have no defined sectionsr�z5new ConfigParser should have no acknowledged sectionsrB�barrJ)rB)r�rB)r-rar`rrZhas_sectionrjr2rkr�r��	get_errorrvr�rl�r	r0r�r
r
r�test_query_errors0s ��(,
zBasicTestCase.test_query_errorsc
CsTz|�||�Wn(|y8}z|WYd}~Sd}~00|�d|j|jf�dS)Nzexpected exception type %s.%s)reZfailrr)r	r0r�rEr�r�r
r
rr�As
�zBasicTestCase.get_errorcCsn|�dj|jdd��}tdd�D]F}|�|�dd|��|�|�dd|��|�t|jdd	|�q"dS)
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
�ZBOOLTESTzt%dzf%dze%d)	r1r~r"�rangerqrirrrjrw)r	r0�xr
r
r�test_booleanJs���zBasicTestCase.test_booleancCsP|��}|�d�|�tj��}|�d�Wd�n1s>0Y|j}|�t|�d�|�|jd�|j	�rL|�tj��2}|j
t�dj
|jdd��dd�Wd�n1s�0Y|j}|�t|�d	�|�|jd
�|�tj��$}|�ddd
d�i�Wd�n1�s0Y|j}|�t|�d�|�|jd�dS)Nr�zSection 'Foo' already exists)r�NNz�                    [Foo]
                    will this be added{equals}True
                    [Bar]
                    what about this{equals}True
                    [Foo]
                    oops{equals}this won't
                rr��	<foo-bar>��sourcezFWhile reading from '<foo-bar>' [line  5]: section 'Foo' already exists)r�r�r�r��valzis really `opt`)r�ZOPTzIWhile reading from '<dict>': option 'opt' in section 'Bar' already exists)r�r�z<dict>N)r-r�rjr2r�rura�strrvr'r.r�r�r~r"rr�)r	r0r|r�r
r
r�test_weird_errorscs,
(��$4zBasicTestCase.test_weird_errorscCs�dj|j|jd|jd�}|jr(|d7}|�|�}dD]`}t��}|j||d�|jd}|rhd�|�}dj||jd	�}|jr�|d
7}|�	|�
�|�q6dS)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)Zcommentr(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�r(z"[Valueless]
option-without-value

)r~r"r#r(r!r1r�r��writera�getvalue)r	r�r0r��output�	delimiterZ
expect_stringr
r
r�
test_write�s4���



���zBasicTestCase.test_writecCs�|�dj|jdd��}Gdd�dt�}|�ddd�|�dd|d��|�dd	d�|�dd	|d��|�ddd�|�dd	d�dS)
N�[sect]
option1{eq}foo
r�r{c@seZdZdS)z2BasicTestCase.test_set_string_types.<locals>.mystrN)rrrr
r
r
r�mystr�sr��sect�option1Zsplat�option2)r1r~r"r�r�)r	r0r�r
r
r�test_set_string_types�s�z#BasicTestCase.test_set_string_typescCsJ|jddkr|�d�t�d�}|��}|�|dg�}|�||g�|�|�dd�d�|��}|�|�}|�||g�|�|�dd�d�|��}|�t�	|��}|�||g�|�|�dd�d�|��}|�t�	|�|g�}|�|||g�|�|�dd�d�|��}|�dg�}|�|g�|��}|�g�}|�|g�dS)	Nrr�incompatible format�cfgparser.1�nonexistent-filer7rB�newbar)
r"�skipTestrr�r-�readrare�pathlib�Path)r	Zfile1r0�parsed_filesr
r
r�test_read_returns_file_list�s2



z)BasicTestCase.test_read_returns_file_listcCs�|jddkr|�d�t�d���}|��}|�|�}|�||g�|��}|�d�}|�|g�|��}|�|dg�}|�||g�dS)Nrrr�r�snonexistent-file)r"r�rr��encoder-r�ra)r	Zfile1_bytestringr0r�r
r
r�0test_read_returns_file_list_with_bytestring_path�s


z>BasicTestCase.test_read_returns_file_list_with_bytestring_pathcCs|�dj|jdd��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
rr�)r1r~r"rr
r
r�get_interpolation_config�s
��z&BasicTestCase.get_interpolation_configcCs~|jd�|j�ddid�}t|jdddid��}|��|�||�|�tj	��|�d�Wd�n1sp0YdS)	Nz�
            [section]
            name {0[0]} %(value)s
            key{0[1]} |%(name)s|
            getdefault{0[1]} |%(default)s|
        �default�	<default>r�rErJrVzno such section)
r1r~r"rbrr_rarjr2rk)r	r�r0rzr
r
r�check_items_configs��z BasicTestCase.check_items_configcCs�|jd�|j�ddid�}|�|��dd�|�|��dd�|�|��dd�|�t��|��Wd�n1s~0YdS)	N��
            [section1]
            name1 {0[0]} value1
            [section2]
            name2 {0[0]} value2
            [section3]
            name3 {0[0]} value3
        r�r�r�r�section1�section2�section3)r1r~r"ra�popitemrjrpr�r
r
r�test_popitem!s��zBasicTestCase.test_popitemcCs�|�ddi�}|�|�|jd�dd�ddd�|d<|�|��dg�|�t|d���hd	��|��|�t|���t��|�t||j���dh�dS)
NrBr�r�r��value1r�)r�r�Zzing>rBr�r�)r-rarer(r`r�r�clearr�r
r
r�
test_clear0s�zBasicTestCase.test_clearcCsB|jd�|j�ddid�}|�t|d���ddh�|�t|d���d	dh�|�t|d
���ddh�|�|ddd�|�|dd	d
�|�|d
dd�|�|��gd��ddi|d<|�t|d���ddh�|�|ddd�|�d	|d�|�|��gd��i|d
<|�t|d
���dh�|�d|d
�|�|��gd��||j||j<|�	t||j���t��i||j<|�t||j���t��|�t|d���dh�|�t|d���dh�|�t|d
���t��|�|��gd��|d|d<|�t|d���dh�dS)Nr�ZnameDZvalueDr�r�Zname1�namedr�Zname2r�Zname3r�r�Zvalue3)r�r�r�Zname22Zvalue22)
r1r~r"rar�rr`�assertNotInr(ZassertNotEqualr�r
r
r�test_setitem<s>��
zBasicTestCase.test_setitemcCs�|jr|�d�t�d�|jd��}|��}|�tj	��|�
|�Wd�n1sZ0Y|�|�dd�d�|�|ddd�dS)Nz2if no_value is allowed, ParsingError is not raisedzC            [DEFAULT]
            test {0} test
            invalidrZDEFAULT�test)
r!r�r�r�r~r"r-rjr2r�r.rare)r	�invalidr0r
r
r�test_invalid_multiline_valuebs
�(z*BasicTestCase.test_invalid_multiline_valueN)rrrr}r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r
r
r
rr5Es._AI*(
		6!
&r5c@seZdZejZdZdS)�StrictTestCaseTN)rrrr2�RawConfigParserr+r'r
r
r
rr�rsr�c@sReZdZejZdd�Zdd�Zdd�Zdd�Z	d	d
�Z
dd�Zd
d�Zdd�Z
dS)�ConfigParserTestCasecCs�|��}|j}||�dd�d�||�dd�d�||�dd�d�|�|tjdd�}|jtjkrr|�|jd	�nt	|jtj
�r�|�|jd	�dS)
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)rr��5something %(with11)s lots of interpolation (11 steps))r�rarer�r2�InterpolationDepthErrorr)r4rv�
isinstance�LegacyInterpolation)r	r0r{r�r
r
r�test_interpolationzs��z'ConfigParserTestCase.test_interpolationcCs�|��}|�|tjdd�}|�|jd�|�|jd�|�|jd�|jtj	kr`|�|j
d�nt|jtj�r||�|j
d�dS)N�Interpolation Errorrd�	reference)rdr	z
%(reference)sr
)
r�r�r2�InterpolationMissingOptionErrorrar
rEr�r)r4rvrrr�r
r
r� test_interpolation_missing_value�s
�z5ConfigParserTestCase.test_interpolation_missing_valuecCs|�gd��dS)N)�r�r�)�
getdefaultz|<default>|)r�z|value|)rdrJ�r�rr
r
r�
test_items�szConfigParserTestCase.test_itemscCs�|�dj|jdd��}|�|�dd�d�|jtjkrN|�|�dd�d�nDt|jtj	�r�|�
t��|�dd�Wd�n1s�0YdS)	Nzc[section]
option1{eq}xxx
option2{eq}%(option1)s/xxx
ok{eq}%(option1)s/%%s
not_ok{eq}%(option2)s/%%srr�rE�okzxxx/%sZnot_okz
xxx/xxx/%s)r1r~r"rarer)r2r4rrrj�	TypeErrorr�r
r
r�test_safe_interpolation�s�z,ConfigParserTestCase.test_safe_interpolationcCs�|�dj|jdd��}|�|�dd�d�|�t|jddd�|�t|jddd�|�t|jddd	�|�|�dd�d�|�dd
d�|�|�dd
�d�dS)
Nr�rr�r�r�rB�%foo�foo%�f%oor��foo%%barzfoo%bar)r1r~r"rarerjrwr�r�r
r
r�#test_set_malformatted_interpolation�s�z8ConfigParserTestCase.test_set_malformatted_interpolationcCs�|�dj|jdd��}|�t|jddd�|�t|jddd�|�t|jddt��|�t|jddd�|�t|jddd�|�t|jddt��|�t|jdd	d
�|�t|jd	�dS)Nr�rr�r�r�r
g�?r�r�zinvalid opt name!)r1r~r"rjrr��objectr�r�r
r
r�test_set_nonstring_types�s�z-ConfigParserTestCase.test_set_nonstring_typescCs|��}|�t|j|j�dSr)r-rjrwr�r(r�r
r
r�test_add_section_default�sz-ConfigParserTestCase.test_add_section_defaultcCs�|jddid�}|�||jdd�|�||j�d�d�|jddid�}|�||jdd	�|�||j�d�d�d
S)zbpo-23835 fix for ConfigParserr
�333333@r�r[z2.4r��������@r�z5.2N)r-rar(rgrhr�r
r
r�test_defaults_keyword�sz*ConfigParserTestCase.test_defaults_keywordN)rrrr2�ConfigParserr+rrrrrrrrr
r
r
rrwsrc@sDeZdZejZdZe�d��	�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
    cCsT|�|ddd�|�|ddd�|�|ddd�|�|dd	d
�dS)NZnumbers�oner[�twoz%(one)s * 2�threez${common:one} * 3ZhexenZsixteenz${numbers:two} * 8)rar�r
r
r�assertMatchesIni�sz4ConfigParserTestCaseNoInterpolation.assertMatchesInicCs|�|j�}|�|�dSr)r1�inir$r�r
r
r�test_no_interpolation�sz9ConfigParserTestCaseNoInterpolation.test_no_interpolationcCs|��}|�|�d��dS�N�)r-�assertIsNoner.r�r
r
r�test_empty_case�sz3ConfigParserTestCaseNoInterpolation.test_empty_casecCs2Gdd�dtj�}|�}|�|j�|�|�dS)Nc@seZdZdZdS)zbConfigParserTestCaseNoInterpolation.test_none_as_default_interpolation.<locals>.CustomConfigParserN)rrrZ_DEFAULT_INTERPOLATIONr
r
r
r�CustomConfigParser�sr+)r2rr.r%r$)r	r+r0r
r
r�"test_none_as_default_interpolation�szFConfigParserTestCaseNoInterpolation.test_none_as_default_interpolation)rrrr2rr+r)r�r��stripr%r$r&r*r,r
r
r
rr �s
r c@s"eZdZejZe��Zdd�ZdS)�'ConfigParserTestCaseLegacyInterpolationcCs�|�dj|jdd��}|�|�dd�d�|�ddd�|�|�dd�d�|�ddd�|�|�dd�d�|�ddd	�|�|�dd�d	�|�dd
d�|�|�dd
�d�dS)Nr�rr�r�r�rBrrrr�r)r1r~r"rarer�r�r
r
rrs�zKConfigParserTestCaseLegacyInterpolation.test_set_malformatted_interpolationN)	rrrr2rr+rr)rr
r
r
rr.�sr.c@seZdZdZdZdZdS)�)ConfigParserTestCaseNonStandardDelimiters�z:=�$��//�"N�rrrr"r#r$r
r
r
rr/sr/c@seZdZdZdS)�-ConfigParserTestCaseNonStandardDefaultSectionZgeneralN)rrrr(r
r
r
rr6sr6c@s6eZdZejZd�dd�Zdd�Zdd�Z	dd	�Z
d
S)�MultilineValuesTestCasezSI'm having spam spam spam spam spam spam spam beaked beans spam spam spam and spam!� �	
cCs�|��}td�D]<}d�|�}|�|�td�D]}|�|d�|�|j�q0qttjd��}|�	|�Wd�n1sz0YdS)N�dz	section{}�
z
lovely_spam{}�w)
r-r�r~r�r��wonderful_spamr�r�TESTFNr�)r	r0r�s�jr�r
r
r�setUp#s

zMultilineValuesTestCase.setUpcCst�tj�dSr)�os�unlinkrr>rr
r
r�tearDown-sz MultilineValuesTestCase.tearDowncCs^|��}ttj��}|�|�Wd�n1s20Y|�|�dd�|j�dd��dS)NZsection8Zlovely_spam4r9�
)	r-r�rr>r�rarer=�replace)r	Zcf_from_filer�r
r
r� test_dominating_multiline_values0s(�z8MultilineValuesTestCase.test_dominating_multiline_valuesN)rrrr2rr+rFr=rArDrGr
r
r
rr7s�
r7c@s2eZdZejZdd�Zdd�Zdd�Zdd�Z	d	S)
�RawConfigParserTestCasecCsZ|��}|j}||�dd�d�||�dd�d�||�dd�d�||�dd�d	�dS)
Nr�r�z*something %(with1)s interpolation (1 step)rz3something %(with9)s lots of interpolation (9 steps)rz5something %(with10)s lots of interpolation (10 steps)rr)r�rare�r	r0r{r
r
rr=s����z*RawConfigParserTestCase.test_interpolationcCs|�gd��dS)N)r
)rz
|%(default)s|)r�z
|%(name)s|)rdz	%(value)srrr
r
rrIsz"RawConfigParserTestCase.test_itemscCs�|��}|�d�|�ddd�|�ddgd��|�ddddi�|�|�dd�d�|�|�dd�gd��|�|�dd�ddi�|�d	�|�d	d
d�|�|�d	d
�d�|jtjur�dd
�|_|�ddd�|�|�dd�d�dS)Nz
non-stringrMr
rb)rr
r
��r���
r*�pign��!	@r�zthis is sickTcSs|Srr
)r�r
r
r�<lambda>_rzBRawConfigParserTestCase.test_set_nonstring_types.<locals>.<lambda>)	r-r�r�rare�_dictr2r3�optionxformr�r
r
rrOs"
�

z0RawConfigParserTestCase.test_set_nonstring_typescCsz|�t�� }|jddid�Wd�n1s00Y|j}|�t|�d�|jddid�}|�||jdd�dS)	z-bpo-23835 legacy behavior for RawConfigParserr
rr�Nz%'int' object has no attribute 'lower'r�rr�)rjror-rurar�rgr()r	�ctx�errr0r
r
rrcs.z-RawConfigParserTestCase.test_defaults_keywordN)
rrrr2r�r+rrrrr
r
r
rrH:s
rHc@seZdZdZdZdZdS)�,RawConfigParserTestCaseNonStandardDelimitersr0r2Nr5r
r
r
rrTmsrTc@s&eZdZejZdZdZdZdd�Z	dS)�RawConfigParserTestSambaConf)rrz----)r3FcCs�t�d�}|��}|j|dgdd�}|�||g�gd�}|�|��|�|�|�dd�d�|�|�dd	�d
�|�|�dd�d�|�|�d
d�d�dS)Nzcfgparser.2r�r�r�)�globalZhomesZprinterszprint$z
pdf-generator�tmpZAgustinrVZ	workgroupZMDKGROUPzmax log size�2zhosts allowz127.rWzecho commandz
cat %s; rm %s)rr�r-r�rar`rerf)r	Zsmbconfr0r�r`r
r
r�test_readingys
z)RawConfigParserTestSambaConf.test_readingN)
rrrr2r�r+r#r$r%rYr
r
r
rrUss
rUc@s\eZdZejZe��ZdZdZ	ddd�Z
dd�Zdd	�Zd
d�Z
dd
�Zdd�Zdd�ZdS)�)ConfigParserTestCaseExtendedInterpolation�commonTNcCs"|�|�}|r||_|�|�|Sr)r-rQr.)r	r/r rQr0r
r
rr1�s


z4ConfigParserTestCaseExtendedInterpolation.fromstringcCsP|�t�d����}|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)r1r�r�r-rarIr
r
r�test_extended_interpolation�s*�zEConfigParserTestCaseExtendedInterpolation.test_extended_interpolationcCs�|�t�d����}|�tj��|ddWd�n1sB0Y|�tj��|ddWd�n1sz0YdS)Nz�
            [one for you]
            ping = ${one for me:pong}

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

            [selfish]
            me = ${me}
        zone for youZpingZselfish�me)r1r�r�r-rjr2rr�r
r
r�test_endless_loop�s
*z;ConfigParserTestCaseExtendedInterpolation.test_endless_loopcCs�|�d�}|�|ddd�|�|ddd�|�|ddd�tj}|�|��}|dd	Wd�n1sx0Y|�|jjd
�|�|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:${sickrJz${dollars:${sick}})r1rar2rrjrur
rv)r	r0Zexception_classr|r
r
r�test_strange_options�s
*z>ConfigParserTestCaseExtendedInterpolation.test_strange_optionscCs�t�d���}|�|�}|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[ZoptionlowerrJZOptionUpper�Value�Common�a better value�A Better Value�randomZfoolower�value redefinedZFooUpper�A Better Value Redefined)r�r�r-r1ra�r	r%r0r{r
r
r�test_case_sensitivity_basic�s
zEConfigParserTestCaseExtendedInterpolation.test_case_sensitivity_basiccCs�t�d���}|�tj��|�|�}Wd�n1s:0Y|j|dd�d�}|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
        cSs|Srr
)r�r
r
rrOrz[ConfigParserTestCaseExtendedInterpolation.test_case_sensitivity_conflicts.<locals>.<lambda>)rQr[r�rJr�r`rarbrcrdrBrer�rf)r�r�r-rjr2rr1rargr
r
r�test_case_sensitivity_conflicts�s
(zIConfigParserTestCaseExtendedInterpolation.test_case_sensitivity_conflictscCs`|�d�}|�tj��|ddWd�n1s80Y|�tj��|ddWd�n1sp0Y|�tj��|ddWd�n1s�0Y|�tj��|ddWd�n1s�0Y|�tj��|ddWd�n1�s0Y|�t��d|dd	<Wd�n1�sR0YdS)
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)r1rjr2�InterpolationSyntaxErrorrrwr�r
r
r�test_other_errorss
	****,z;ConfigParserTestCaseExtendedInterpolation.test_other_errors)NN)rrrr2rr+�ExtendedInterpolationr)r(r'r1r\r^r_rhrirkr
r
r
rrZ�s
-rZc@seZdZdZdS)�ConfigParserTestCaseNoValueTN)rrrr!r
r
r
rrm2srmc@s2eZdZejZdhZdhZdZdd�Z	dd�Z
dS)	�ConfigParserTestCaseTrickyFilerrTcCs�t�d�}|��}|�t|j|dd��d�|�|��gd��|�|j|jdddid	�d
�|�	t
��(|j|jddddid�Wd�n1s�0Y|�t|�d
d��d��d�|�t|�dd��d��d�d}|�
|�|d��|�|�|d�d�|�t|�d��d�|�	tj��|�d�Wd�n1�sJ0Y|�|�dd�d�|�|�dd�|�dd��|�|�dd�d�dS) Nr�r�r�r
)�strange�
corruption�&yeah, sections can be indented as well�another one!�no values here�tricky interpolation�more interpolationZgoZinterpolatez-1rV���T)�rawrWro�otherrE�rprJr;rqzare they subsectionszlets use some Unicodeu	片仮名rrr�rsrtZletszdo thisruzgo shopping)rr�r-rarcr�r`rfr(rjrwre�splitrrrirr2r)r	r�r0Zlongnamer
r
r�test_cfgparser_dot_3<s4
���$*
�z3ConfigParserTestCaseTrickyFile.test_cfgparser_dot_3cCsNt�d�}|��}|�t��|j|dd�Wd�n1s@0YdS)Nr��asciir�)rr�r-rj�UnicodeDecodeErrorr�)r	r�r0r
r
r�test_unicode_failure\s
z3ConfigParserTestCaseTrickyFile.test_unicode_failureN)rrrr2rr+r"r#r!r{r~r
r
r
rrn6s rnc@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

cCs<|dd�}|�d�|�ddd�t��}|�|�|��S�NF)r!rEr�)r�r�r�r�r�r�)r	r+�cpr�r
r
r�preparels


zIssue7005TestCase.preparecCsRtjdd�}|�d�|�t��|�ddd�Wd�n1sD0YdSr�)r2rr�rjrr�)r	r�r
r
r�test_none_as_value_stringifiedus
z0Issue7005TestCase.test_none_as_value_stringifiedcCs|�tj�}|�||j�dSr)r�r2r�ra�expected_output)r	r�r
r
r�"test_none_as_value_stringified_raw{sz4Issue7005TestCase.test_none_as_value_stringified_rawN)rrr�__doc__r�r�r�r�r
r
r
rrcs
	rc@seZdZeZdd�ZdS)�SortedTestCasecCs0|�d�}t��}|�|�|�|��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

)r1r�r�r�rar�)r	r0r�r
r
r�test_sorted�s


�zSortedTestCase.test_sortedN)rrrrr&r�r
r
r
rr��sr�c@s"eZdZejZdZdZdd�ZdS)�CompatibleTestCasez#;rcCsTt�d�}|�|�}|�|�dd�d�|�|�dd�d�|�|�dd�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
        r6rBzbar # not a comment!r@rAZquirkzthis;is not a comment)r�r�r1rarer�r
r
r�test_comment_handling�s
	
��z(CompatibleTestCase.test_comment_handlingN)	rrrr2r�r+r#r$r�r
r
r
rr��sr�c@seZdZejZddd�ZdS)�CopyTestCaseNcCsp|�|�}|�|�|��}|�|�|��D]<}|j|jkr@q.||j��D]\}}|||krN||=qNq.|Sr)r-r.r�rrdr(r)r	r/r r0Zcf_copyrEr�rJr
r
rr1�s



zCopyTestCase.fromstring)N)rrrr2rr+r1r
r
r
rr��sr�c@seZdZdd�Zdd�ZdS)�FakeFilecCsJt�d�}t|��$}|��|_|j��Wd�n1s<0YdS)Nr�)rr�r��	readlines�lines�reverse)r	�	file_pathr�r
r
r�__init__�s


zFakeFile.__init__cCst|j�r|j��SdSr')rcr��poprr
r
rr��s

zFakeFile.readlineN)rrrr�r�r
r
r
rr��sr�ccs |��}|r|V|��}qdS)z+As advised in Doc/library/configparser.rst.N)r�)r��liner
r
r�readline_generator�sr�c@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�ReadFileTestCasec	Cs�t�d�g}z|�|d�d��Wnty6Yn0|D]n}t��}t|��}|�|�Wd�n1sp0Y|�	d|�|�	d|d�|�
|ddd�q<dS)Nr�r�utf8r7rBr�)rr�r^r��UnicodeEncodeErrorr2rr�r��assertInra)r	Z
file_pathsr�rnr�r
r
r�	test_file�s
(zReadFileTestCase.test_filecCsZt�d����d�}t��}|�|�|�d|�|�d|d�|�|ddd�dS)Nz%
        [Foo Bar]
        foo=newbarrEr7rBr�)	r�r�r-rzr2rr�r�ra)r	r�rnr
r
r�
test_iterable�s�
zReadFileTestCase.test_iterablecCs�t��}|�t��|�t��Wd�n1s40Y|�tt���|�d|�|�d|d�|�|ddd�dS)z
Issue #11670.Nr7rBr�)	r2rrjrr�r�r�r�ra�r	rnr
r
r�test_readline_generator�s*z(ReadFileTestCase.test_readline_generatorcCs�t�d����d�}t��}|�tj��}|j|dd�Wd�n1sL0Y|�	t
|j�d�t�d����d�}t��}|�tj��}|j|dd�Wd�n1s�0Y|�	t
|j�d�t�d	����d�}t��}|�tj
��}|j|dd�Wd�n1�s0Y|�	t
|j�d
�t�d����d�}t��}|�tj��}|j|dd�Wd�n1�s�0Y|�	t
|j�d�dS)
z
Issue #18260.z"
        [badbad]
        [badbad]rEsbadbadr�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-rzr2rrjr�r�rar�rurr�r�)r	r�rnZdser
r
r�test_source_as_bytes�sP�,��,��.��.�z%ReadFileTestCase.test_source_as_bytesN)rrrr�r�r�r�r
r
r
rr��s

r�c@sPeZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�ZdS)�CoverageOneHundredTestCasez"Covers edge cases in the codebase.cCsft�dd�}|�|jd�|�|jd�|�|jd�|�|jd�|�|jd�|�t|�d�dS)NrEr�)rEr�NNz3Option 'option' in section 'section' already exists)	r2rrarEr�r��linenorvr��r	r�r
r
r�test_duplicate_option_error+sz6CoverageOneHundredTestCase.test_duplicate_option_errorcCs<t�ddd�}|�|jd�|�|jd�|�|jd�dS)Nr�rE�rawval)r�rEr�)r2rrarvr�rEr�r
r
r�test_interpolation_depth_error5s�z9CoverageOneHundredTestCase.test_interpolation_depth_errorcCs"|�t��}t��Wd�n1s(0Y|�t|j�d�|�t��}tjddd�Wd�n1sr0Y|�t|j�d�tjdd�}|�|jd�tj	dd��>}t�
d	t�|�|jd�d|_|�|jd�Wd�n1s�0Y|D]}|�
|jtu��qdS)
Nz%Required argument `source' not given.r��filename)r�r�z:Cannot specify both `filename' and `source'. Use `source'.�r�T��record�always)rjrwr2r�rar�rur��warnings�catch_warnings�simplefilter�DeprecationWarningr�rq�category)r	r|r�r<�warningr
r
r�test_parsing_error<s&,,z-CoverageOneHundredTestCase.test_parsing_errorcCs�t��}|�d�|�tj��}|ddWd�n1s@0Y|�t|j�d�|�tj��}|ddWd�n1s�0Y|�t|j�d�dS)Nz�
            [section]
            invalid_percent = %
            invalid_reference = %(()
            invalid_variable = %(does_not_exist)s
        rEZinvalid_percentz.'%' must be followed by '%' or '(', found: '%'Zinvalid_referencez+bad interpolation variable reference '%(()')r2rr.rjrjrar�ru�r	rnr|r
r
r�test_interpolation_validationOs
**z8CoverageOneHundredTestCase.test_interpolation_validationcCs�t�d�}t��}tjdd��*}t�dt�|j|dd�Wd�n1sN0Y|D]}|�	|j
tu�q\|�t|�d�|�|dd	d
�dS)Nz2
        [section]
        option = value
        Tr�r�r�r�rJrEr�rJ)
r�r�r2rr�r�r�r�Zreadfprqr�rarc)r	r�rnr<r�r
r
r�test_readfp_deprecation`s
,z2CoverageOneHundredTestCase.test_readfp_deprecationcCs^tjdd��$}t�dt�t��}Wd�n1s60Y|D]}|�|jtu�qDdS)NTr�r�)r�r�r�r�r2ZSafeConfigParserrqr�)r	r<rnr�r
r
r�!test_safeconfigparser_deprecationns
&z<CoverageOneHundredTestCase.test_safeconfigparser_deprecationcCs*t��}|�d�|�t|d�d�dS)Nz7
            [section]
            key = value
        rEz<Section: section>)r2rr.ra�reprr�r
r
r�test_sectionproxy_reprus
z1CoverageOneHundredTestCase.test_sectionproxy_reprcCs�t��}ddl}|j|jd<|�d�|�d|j�|�|�dd�d�|�|�dd�d	�|�|d�d�d�|�|d�d�d	�|`|�	t
��|�dd�Wd�n1s�0Y|�d|j�|jd=|�d|j�|�	t
��|�dd�Wd�n1�s0Y|�	t
��|d�d�Wd�n1�sN0Y|�	t
��|d�d�Wd�n1�s�0YdS)
Nr�decimalzS
            [s1]
            one = 1
            [s2]
            two = 2
        �s1r!r
�s2r"rJ)r2rr��Decimal�
convertersr.r�ra�
getdecimalrjror�)r	rnr�r
r
r�"test_inconsistent_converters_state}s*
*,.z=CoverageOneHundredTestCase.test_inconsistent_converters_stateN)rrrr�r�r�r�r�r�r�r�r�r
r
r
rr�(s
r�c@sheZdZdZdd�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.cCsdddl}t�d�}t|jd�D]>}|�||�}|�|�}|�|j|j�|�t	|�t	|��q dS)NrrJr
)
�pickler2�Errorr��HIGHEST_PROTOCOL�dumps�loadsra�messager��r	r��e1�protoZpickled�e2r
r
r�
test_error�s

z$ExceptionPicklingTestCase.test_errorcCs�ddl}t�d�}t|jd�D]^}|�||�}|�|�}|�|j|j�|�|j	|j	�|�|j
|j
�|�t|�t|��q dS)NrrEr
)r�r2rkr�r�r�r�rar�rvrEr�r�r
r
r�test_nosectionerror�s

z-ExceptionPicklingTestCase.test_nosectionerrorcCs�ddl}t�dd�}t|jd�D]n}|�||�}|�|�}|�|j|j�|�|j	|j	�|�|j
|j
�|�|j|j�|�t|�t|��q"dS)Nrr�rEr
)
r�r2rlr�r�r�r�rar�rvrEr�r�r�r
r
r�test_nooptionerror�s
z,ExceptionPicklingTestCase.test_nooptionerrorcCs�ddl}t�ddd�}t|jd�D]~}|�||�}|�|�}|�|j|j�|�|j	|j	�|�|j
|j
�|�|j|j�|�|j|j�|�t
|�t
|��q$dS)NrrEr�r�r
)r�r2r�r�r�r�r�rar�rvrEr�r�r�r�r
r
r�test_duplicatesectionerror�s
z4ExceptionPicklingTestCase.test_duplicatesectionerrorcCs�ddl}t�dddd�}t|jd�D]�}|�||�}|�|�}|�|j|j�|�|j	|j	�|�|j
|j
�|�|j|j�|�|j|j�|�|j
|j
�|�t|�t|��q&dS)NrrEr�r�r�r
)r�r2rr�r�r�r�rar�rvrEr�r�r�r�r�r
r
r�test_duplicateoptionerror�s
�
z3ExceptionPicklingTestCase.test_duplicateoptionerrorcCs�ddl}t�ddd�}t|jd�D]n}|�||�}|�|�}|�|j|j�|�|j	|j	�|�|j
|j
�|�|j|j�|�t|�t|��q$dS�Nrr�rE�msgr
)
r�r2ZInterpolationErrorr�r�r�r�rar�rvrEr�r�r�r
r
r�test_interpolationerror�s
z1ExceptionPicklingTestCase.test_interpolationerrorcCs�ddl}t�dddd�}t|jd�D]~}|�||�}|�|�}|�|j|j�|�|j	|j	�|�|j
|j
�|�|j|j�|�|j|j�|�t
|�t
|��q&dS)Nrr�rEr�r
r
)r�r2rr�r�r�r�rar�rvrEr�r
r�r�r
r
r�$test_interpolationmissingoptionerror�s�
z>ExceptionPicklingTestCase.test_interpolationmissingoptionerrorcCs�ddl}t�ddd�}t|jd�D]n}|�||�}|�|�}|�|j|j�|�|j	|j	�|�|j
|j
�|�|j|j�|�t|�t|��q$dSr�)
r�r2rjr�r�r�r�rar�rvrEr�r�r�r
r
r�test_interpolationsyntaxerror�s
z7ExceptionPicklingTestCase.test_interpolationsyntaxerrorcCs�ddl}t�ddd�}t|jd�D]n}|�||�}|�|�}|�|j|j�|�|j	|j	�|�|j
|j
�|�|j|j�|�t|�t|��q$dS)Nrr�rEr�r
)
r�r2rr�r�r�r�rar�rvrEr�r�r�r
r
r�test_interpolationdeptherror�s�
z6ExceptionPicklingTestCase.test_interpolationdeptherrorcCsfddl}t�d�}|�dd�|�dd�|�dd�t|jd�D]n}|�||�}|�|�}|�|j	|j	�|�|j
|j
�|�|j|j�|�|j|j�|�t
|�t
|��qDtjd	d
�}|�dd�|�dd�|�dd�t|jd�D]n}|�||�}|�|�}|�|j	|j	�|�|j
|j
�|�|j|j�|�|j|j�|�t
|�t
|��q�dS)Nrr�r
Zline1rJZline2rKZline3r�r�)r�r2r�r^r�r�r�r�rar�rvr��errorsr�r�r
r
r�test_parsingerrors2


z+ExceptionPicklingTestCase.test_parsingerrorcCs�ddl}t�ddd�}t|jd�D]~}|�||�}|�|�}|�|j|j�|�|j	|j	�|�|j
|j
�|�|j|j�|�|j|j�|�t
|�t
|��q$dS)Nrr�r�r�r
)r�r2r�r�r�r�r�rar�rvr�r�r�r�r�r
r
r�test_missingsectionheadererror's
z8ExceptionPicklingTestCase.test_missingsectionheadererrorN)rrrr�r�r�r�r�r�r�r�r�r�r�r�r
r
r
rr��s	

r�c@seZdZdZdd�ZdS)�InlineCommentStrippingTestCasez}Tests for issue #14590: ConfigParser doesn't strip inline comment when
    delimiter occurs earlier without preceding space..cCs�tjdd�}|�d�|d}|�|dd�|�|dd�|�|d	d
�|�|dd�|�|d
d�|�|dd�|�|dd�|d}|�|dd�|�|dd�|�|d	d�dS)N)rrr3)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
        rEZk1zv1;still v1Zk2Zv2Zk3Zv3Zk4zv4;still v4Zk5zv5;still v5Zk6zv6;still v6; and still v6Zk7zv7;still v7; and still v7Zmultiprefixzv3;#//still v3# and still v3)r2rr.ra)r	�cfgr?r
r
r�test_stripping9s
z-InlineCommentStrippingTestCase.test_strippingN)rrrr�r�r
r
r
rr�5sr�c@s8eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�ZdS)
�ExceptionContextTestCasezO Test that implementation details doesn't leak
    through raising exceptions. cCsbt��}|�d�|�tj�}|�|�dd�Wd�n1sD0Y|�|jjd�dS)Nz�
        [Paths]
        home_dir: /Users
        my_dir: %(home_dir1)s/lumberjack
        my_pictures: %(my_dir)s/Pictures
        �Paths�my_dirT)	r2rr.rjrrermru�__suppress_context__r�r
r
r�test_get_basic_interpolation]s
*z5ExceptionContextTestCase.test_get_basic_interpolationcCsjtjt��d�}|�d�|�tj�}|�|�dd�Wd�n1sL0Y|�|jj	d�dS)N)r)z�
        [Paths]
        home_dir: /Users
        my_dir: ${home_dir1}/lumberjack
        my_pictures: ${my_dir}/Pictures
        r�r�T)
r2rrlr.rjrrermrur�r�r
r
r�test_get_extended_interpolationjs�
*z8ExceptionContextTestCase.test_get_extended_interpolationcCs\t��}|�d�|�tj��}|�d�Wd�n1s>0Y|�|jjd�dS)Nz2
        [Paths]
        home_dir: /Users
        r�T)	r2rr.rjrkr�rmrur�r�r
r
r�test_missing_optionsxs

(z-ExceptionContextTestCase.test_missing_optionscCsVt��}|�tj��}|�ddd�Wd�n1s80Y|�|jjd�dS)N�Section1�an_intZ15T)r2rrjrkr�rmrur��r	r�r|r
r
r�test_missing_section�s,z-ExceptionContextTestCase.test_missing_sectioncCsTt��}|�tj��}|�dd�Wd�n1s60Y|�|jjd�dS)Nr�r�T)r2rrjrkrtrmrur�r�r
r
r�test_remove_option�s*z+ExceptionContextTestCase.test_remove_optionN)	rrrr�r�r�r�r�r�r
r
r
rr�Ys

r�cs0eZdZdZejZd�fdd�	Zdd�Z�Z	S)�ConvertersTestCasez Introduced in 3.5, issue #18159.Ncs t�j|d�}dd�|jd<|S)Nr�cSsdd�|��D�S)NcSsg|]}|��r|���qSr
)r-)rr�r
r
rr�s�zBConvertersTestCase.newconfig.<locals>.<lambda>.<locals>.<listcomp>)rz��vr
r
rrO�rz.ConvertersTestCase.newconfig.<locals>.<lambda>rb)�superr-r�)r	r r,��	__class__r
rr-�szConvertersTestCase.newconfigcCs�|��}|�d|j�|�d|j�|�|jd�|�|jd�|�|jd�|�|jd�|�t|j�d�|�t��dd�|jd<Wd�n1s�0Y|�t��d	d�|jd<Wd�n1s�0Y|�	d
�|d}|�|dd
�|�|dd�|�|dd�|�|dd�|�|dd�|�|�
dd�d
�|�|�
dd�d�|�|�
dd�d�|�|�
dd�d�|�|�
dd�d�|�|�
dd�d
�|�|�dd�d�|�|�dd�d�|�|�
dd�gd��|�|�dd�d�|�|�
d�d
�|�|�d�d�|�|�d�d�|�|�
d�gd��|�|�d�d�|�t��|�dd�Wd�n1�s�0Y|�t��|�d�Wd�n1�s�0Yddl}|j|jd<|�d|j�|�|jd�|�t|j�d�|�d�}|�|�dd�|�|�|�d�|�|jd=|�d|j�|�t|j�d�|�t��|�dd�Wd�n1�s�0Y|�t��|�d�Wd�n1�s�0Y|�t��|jd=Wd�n1�s0Y|�t��|jd=Wd�n1�sH0Y|�t��|jd=Wd�n1�s|0YdS)NrQrbrMrOrycSs|Srr
r�r
r
rrO�rz4ConvertersTestCase.test_converters.<locals>.<lambda>r(cSs|Srr
r�r
r
rrO�rz~
        [s]
        str = string
        int = 1
        float = 0.5
        list = a b c d e f g
        bool = yes
        r?r�r/r[z0.5z
a b c d e f g�boolrYr
g�?)r�r��c�dr�r��gTrr�r�)r-r�r�r)�assertIsNotNonerarcrjrwr.rerfrhZgetlistriror�r�r�r�rp)r	r�r?r�Zdec0_5r
r
r�test_converters�sv,,
,*
,*((z"ConvertersTestCase.test_converters)N)
rrrr�r2rr+r-r��
__classcell__r
r
r�rr��sr�c@s4eZdZdZdZdd�Zdd�Zdd�Zd	d
�ZdS)�!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
    cCs:tjdtid�}|�|j�|�|�|�|jd�dS)Nrc)r�)r2rrcr.r��	_test_lenr�r��r	r�r
r
r�test_converters_at_init�s
z9BlatantOverrideConvertersTestCase.test_converters_at_initcCs�Gdd�dtj�}|�}|�|j�|�|�|�|jd�|�|�dd��|�|�dd��|�	|�dd��|�	|�dd��|j
|jd<|�	|�dd��|�	|�dd��|�	|�dd��|�	|�dd��dS)Ncs@eZdZdZddejd��fdd�
Zddejd�dd�Z�ZS)	zOBlatantOverrideConvertersTestCase.test_inheritance.<locals>.StrangeConfigParserz0a historic borough in south central PennsylvaniaFN�rwrWrUcs"||krdSt�j|||||d�S)NTr�)r�ri�r	rEr�rwrWrUr�r
rri�s
�zZBlatantOverrideConvertersTestCase.test_inheritance.<locals>.StrangeConfigParser.getbooleancSs|j||t|||d�S)Nr�)Z	_get_convrcr�r
r
r�getlens�zVBlatantOverrideConvertersTestCase.test_inheritance.<locals>.StrangeConfigParser.getlen)	rrrZ
gettysburgr2r4rir�r�r
r
r�r�StrangeConfigParser�s��r�rcr!r"rQ)r2rr.r�r�r)r�rqrirr�_convert_to_boolean)r	r�r�r
r
r�test_inheritance�s
z2BlatantOverrideConvertersTestCase.test_inheritancecCs�|�t|j�d�|�d|j�|�d|j�|�d|j�|�|jd�|�|jd�|�|jd�|�|�dd�d�|�|�dd	�d�|�|�dd
�d�|�|�d	d�d�|�|�d	d	�d�|�|�d	d
�d�|�|jd	dd
d�d
�|�tj	��|�d	d�Wd�n1�s,0Y|�|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�dS)NryrQrcZtysburgrMrOr!r�r"r#�ZfourrrT)
rarcr�r�r�r)r�rjr2rlr�r
r
rr�s0,z+BlatantOverrideConvertersTestCase._test_lencs&t���dd��_�fdd��_��|j�|�t�j�d�|�	d�j�|�
d�j�|��jd�|��jd�|��jd�|���d	d	��|���d
d
��|���d	d
��|���d
d	���j
�jd<|���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�|�t��&|��d	�d	�d�Wd�n1�s�0Y|�t��&|��d
�d	�d�Wd�n1�s0YdS)NcSsdS)NTr
�rEr�r
r
rrO0rzLBlatantOverrideConvertersTestCase.test_instance_assignment.<locals>.<lambda>cst�||�Sr)rcr��r�r
rrO1rrKrQrcrMrOr!r"r�r#r�ry)r2rrir�r.r�rarcr�r�r�r)rqr�rrrjrorr
r�r�test_instance_assignment.s:
6z:BlatantOverrideConvertersTestCase.test_instance_assignmentN)	rrrr�r�r�r�r�r�r
r
r
rr��sr�c@seZdZdd�ZdS)�MiscTestCasecCsdh}tj|t|d�dS)Nr�)�	blacklist)rZcheck__all__r2)r	rr
r
r�test__all__QszMiscTestCase.test__all__N)rrrrr
r
r
rrPsr�__main__),�collectionsr2r�rBr�r�Zunittestr�r�r�UserDictrrr5ZTestCaser�rr r.r/r6r7rHrTrUrZrmrnrr�r�r�r�r�r�r�r�r�r�r�r�rr�mainr
r
r
r�<module>s`!3b$3,-
Sr$6Ro


Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists