HEX
Server: Apache
System: Linux zacp120.webway.host 4.18.0-553.50.1.lve.el8.x86_64 #1 SMP Thu Apr 17 19:10:24 UTC 2025 x86_64
User: govancoz (1003)
PHP: 8.3.26
Disabled: exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Upload Files
File: //usr/local/lib/python3.7/test/__pycache__/test_configparser.cpython-37.opt-2.pyc
B

��g�R�@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.7/test/test_configparser.pyrszSortedDict.itemscCst|j���S)N)rr�keys)rrrr	r
szSortedDict.keyscCsdd�|��D�S)NcSsg|]}|d�qS)�r)�.0�irrr	�
<listcomp>sz%SortedDict.values.<locals>.<listcomp>)r)rrrr	�valuesszSortedDict.valuescCst|���S)N)�iterr)rrrr	�	iteritemsszSortedDict.iteritemscCst|���S)N)rr
)rrrr	�iterkeysszSortedDict.iterkeyscCst|���S)N)rr)rrrr	�
itervaluesszSortedDict.itervaluesN)
�__name__�
__module__�__qualname__rr
rrrr�__iter__rrrr	r
src@sJeZdZdZdZdZdZdZej	Z
dZejZ
ejZd
dd�Zddd	�ZdS)�CfgParserTestCaseClassF)�=�:)�;�#TNcCs>t||j|j|j|j|j|j|j|j|j	d�
}|j
f|�}|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|�|�}|�|�|S)N)r*�read_string)r�stringr�cfrrr	�
fromstring?s

z!CfgParserTestCaseClass.fromstring)N)N)rrrrrr r!r"�configparser�
_default_dictr#r$ZDEFAULTSECTr%�_UNSETr&r*r.rrrr	r$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�ddddddddd	g	}|jr&|�d
�|��ddg}|��}|��|j}|||�|�d�}|��|||�d
d�|D�}|��|�|j�|��|||�|d��}tt|��}|||�|��}tt|��}|�t	|�t	|��x|D]\}}|||j
�q�W||��||j�||�dd�d�||�dd�d�||�dd�d�||�dd�d�||�dd�d�||�dd�d�||�dd�d�||�dd�d�||�
d	d�d�||�d	d�d�|�|�d	d�d�||�d	d�d�||�d	d �d!�||�d	d"�d#�|j�r:||�d
d$�d�||jdddd%�d�||jddddid&�d�|�tj��|�d'd�WdQRX|�tj��|�dd(�WdQRX||jd'ddd%�d�||jdd(dd%�d�||jdddd%�d�||jd)ddd%�d�||j
d	dd*d%�d�||j
d	d+d*d%�d*�||j
d	d+d,d%�d,�|�tj��|�
d	d+�WdQRX|�|jd	dd-d%�d�|�|jd	d.d-d%�d-�||jd	d.d/d%�d/�|�tj��|�d	d.�WdQRX||jd	d d0d%�d!�||jd	d1d2d%�d2�||jd	d1d0d%�d0�|�tj��|�d	d1�WdQRX||jd3d d0d%�d0�|j�r�||jd
d$d!d%�d�||jd
d4d!d%�d!�||ddd�||ddd�|d}||j
d�|�|j|�|�t��d5|_
WdQRX|�t��d6|_WdQRX||dd�||dd�||ddd�||ddd�||ddd�||ddd�||ddd7�|j�r�||d
d$d�||d�dd�d�||djddd%�d�||djdddid&�d�|�t��|d'dWdQRX|�t��|dd(WdQRX|�t��|d'jddd%�WdQRX||d�d(d�d�||djd(dd%�d�||d�d(�d�||d�dd�d�||djddd%�d�|�t��|d)�dd�WdQRX||d	�
dd*�d�||d	j
dd*d%�d�||d	�
d+d*�d*�||d	j
d+d*d%�d*�||d	�
d+d,�d,�||d	j
d+d,d%�d,�||d	�
d+�d�|�|d	�dd-�d�|�|d	jdd-d%�d�|�|d	�d.d-�d-�|�|d	jd.d-d%�d-�||d	�d.d/�d/�||d	jd.d/d%�d/�||d	�d.�d�||d	�d d0�d!�||d	jd d0d%�d!�||d	�d1d2�d2�||d	jd1d2d%�d2�||d	�d1d0�d0�||d	jd1d0d%�d0�||d	�d1�d�|j�	r*||d
�d$d!�d�||d
jd$d!d%�d�||d
�d4d!�d!�||d
jd4d!d%�d!�d8||jd9<d:||jd;<|�|�d��|�|�dd��|�|�d��|�|�|j��|�|�dd�d<�|�|�dd�d=�|�|�dd�d>�|�|�dd9��|�|�dd9��|�|�|jd9��|�|�dd9��|�|�|jd9��|�tj��}|�d?d�WdQRX|�|jjd@�||�dd�d7�|d	=|�d	|k�|�t��|d	=WdQRX|�t ��||j=WdQRX|dd=|�d|dk�|�t��|dd=WdQRX|�d;|dk�|�t��|dd;=WdQRX||jd;=|�d;|dk�|�t��||jd;=WdQRX|�t��|d?d=WdQRXdS)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	rbsz,BasicTestCase.basic_test.<locals>.<listcomp>r8�bar1�bar2r9r6r7�bar4zkey with spaces�valuezanother with spaceszsplat!�int�*Z42�floatg)\��(�?z0.44�booleanFZ123zstrange but acceptablezoption-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-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 removedzNo Such Section)zNo Such Section)!r�append�sort�sections�assertEqualrr%r�list�len�namer�get�getint�assertAlmostEqual�getfloat�
getboolean�assertRaisesr/�NoSectionError�
NoOptionError�assertIs�parser�AttributeError�KeyError�
assertTrueZremove_section�assertFalse�
has_option�
remove_option�	exception�args�
ValueError)	rr-�E�F�L�eqrOr:�cmrrr	�
basic_testGsz







zBasicTestCase.basic_testc	Cs�d�|j|j�}|jr|d7}|�|�}|�|�|jr�|�tj	��|�
t�d�|j���WdQRX|�tj
��|�
t�d�|j���WdQRXn0|�
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
            )�formatrr rr.rhr$rUr/�DuplicateOptionErrorr+�textwrap�dedent�DuplicateSectionError)r�
config_stringr-rrr	�
test_basic%s"

zBasicTestCase.test_basicc
Csddiddiddd�ddd�ddiid	d
ddd
�ddd�ddddd�d�	}|jrb|�dddii�|��}|�|�|�|�|jr�|�tj��|�ddiddid��WdQRX|�tj	��|�dddd �i�WdQRXn,|�ddiddid!��|�dddd �i�dS)"Nr8r;r<r9r7)r8r6r=z7this line is much, much longer than my editor
likes it.Z	BulgarianZDefaultZEnglishZDeutsch)zfoo[bg]r8zfoo[en]zfoo[de]r>zsplat!)zkey with spaceszanother with spacesr@g)\��(�?Fzstrange but acceptable)r?rArB�{)	zFoo Barz
Spacey BarzSpacey Bar From The Beginningz
Commented Barz	Long LinezSection\with$weird%characters[	zInternationalized Stuffr3r4r5zoption-without-value�keyZkey2�value2)rGrzDuplicate Options Herezwith a valuezwith another value)�optionZOPTION)r:ZSECTION)
r�updater*�	read_dictrhr$rUr/rmrj)r�configr-rrr	�test_basic_from_dictfsT

z"BasicTestCase.test_basic_from_dictc	Cs�|��}|�d�|�d�|�d�|��}|��|j}||dddg�|�ddd�||�d�dg�||�dd�dd�|�t	j
��|�ddd�WdQRX|�|�dd��|�
|�dd��|�ddd�x d	D]}|�|�d|�d
�q�W||�d�dg�||�d�dg�|�dd�||�d�g�|�d�|jd
��}||�d�dg�||�dd�d�|jd�|jd
�ddid�}|�|�dd��dS)N�A�a�Br>�bz@could not locate option, expecting case-insensitive option nameszA-Bz	A-B value)za-bzA-bza-BzA-Bz9has_option() returned false for option which should existza-bz3[MySection]
Option{} first line   
	second line   
r�	MySectionrs�Optionzfirst line
second linez[section]
nekey{}nevalue
rq)rr:�Key)r*�add_sectionrKrJrL�set�optionsrPrUr/rVr\r^r]r_r.rir)rr-rerf�optrrr	�test_case_sensitivity�sD






z#BasicTestCase.test_case_sensitivityc	Cs�|��}i|d<ddi|d<i|d<dd�|D�}|��|j}|j}||tdd|jdg��||d��dh�||dddd�|�t��d|dd<WdQRX|�	d|dk�d	|dd
<x dD]}|�	||dkd�q�W||d��d
h�||d��dh�|dd=||d��i�|�
d�|jd��}||d��dh�||ddd�|j
d�|jd�ddid�}|�	d|dk�dS)Nrxrzr>rycSsg|]}|�qSrr)rr:rrr	r�szFBasicTestCase.test_case_sensitivity_mapping_access.<locals>.<listcomp>r{z@could not locate option, expecting case-insensitive option namesz	A-B valuezA-B)za-bzA-bza-BzA-Bz9has_option() returned false for option which should existza-bz3[MySection]
Option{} first line   
	second line   
rr|rsr}zfirst line
second linez[section]
nekey{}nevalue
rq)rr~r:)
r*rJrLZassertCountEqualrr%r
rUr[r\r.rir)rr-rerfZelem_eqr�rrr	�$test_case_sensitivity_mapping_access�sB




z2BasicTestCase.test_case_sensitivity_mapping_accesscCsP|�ddi�}|�|�|jd�dd�|�ddi�}|�|�|jd�dd�dS)Nr8�Bar�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_sensitivitysz+BasicTestCase.test_default_case_sensitivityc	Cs�|��}|�|tjd�|jd��|�|tjd�|jd��|�|tjd�}|�|jd�|j	s�|�|tjd�}|�|jd�t
�d�}|jdd	kr�tj}|f}ntj}|dd
f}t|dd��}|�|||�}WdQRX|�|j|�dS)
Nz[Foo]
{}val-without-opt-name
rrzNo Section!
)z<???>rzNo Section!
z[Foo]
  wrong-indent
)z<???>zcfgparser.3rz.  # INI with as many tricky parts as possible
zutf-8)�encoding)
r*�parse_errorr/�ParsingErrorrir�MissingSectionHeaderErrorrLrarr�findfile�open)rr-�e�tricky�error�expected�frrr	�test_parse_errorss0




zBasicTestCase.test_parse_errorsc	Cs@t|d�r|}n
t�|�}|�|��}|�|�WdQRX|jS)N�readline)�hasattr�io�StringIOrU�	read_filer`)rr-�exc�src�siorgrrr	r�'s

zBasicTestCase.parse_errorc	Cs�|��}|�|��gd�|�|�d�d�|�tj��|�d�WdQRX|�tj��|�	ddd�WdQRX|�
|tjdd�}|�|jd�|�d�|�
|tj
dd�}|�|jd�dS)	Nz0new ConfigParser should have no defined sectionsr�z5new ConfigParser should have no acknowledged sectionsr8�barr>)r8)r�r8)r*rLrKr]Zhas_sectionrUr/rVr�r��	get_errorrarrW)rr-r�rrr	�test_query_errors0s
zBasicTestCase.test_query_errorsc
CsNy|�||�Wn"|k
r2}z|Sd}~XYnX|�d|j|jf�dS)Nzexpected exception type %s.%s)rPZfailrr)rr-r�r:rsr�rrr	r�AszBasicTestCase.get_errorcCsr|�dj|jdd��}xTtdd�D]F}|�|�dd|��|�|�dd|��|�t|jdd	|�q$WdS)
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)	r.rir�ranger\rTr]rUrb)rr-�xrrr	�test_booleanJszBasicTestCase.test_booleanc	Cs|��}|�d�|�tj��}|�d�WdQRX|j}|�t|�d�|�|jd�|j	�r|�tj��(}|j
t�dj
|jdd��dd�WdQRX|j}|�t|�d	�|�|jd
�|�tj��}|�ddd
d�i�WdQRX|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
                r)r�z	<foo-bar>)�sourcezFWhile reading from '<foo-bar>' [line  5]: section 'Foo' already exists)r�z	<foo-bar>r�r��valzis really `opt`)r�ZOPTzIWhile reading from '<dict>': option 'opt' in section 'Bar' already exists)r�r�z<dict>N)r*rrUr/rmr`rL�strrar$r+rkrlrirrjru)rr-rgr�rrr	�test_weird_errorscs&
$zBasicTestCase.test_weird_errorscCs�dj|j|jd|jd�}|jr(|d7}|�|�}xhdD]`}t��}|j||d�|jd}|rjd�|�}dj||jd	�}|jr�|d
7}|�	|�
�|�q8WdS)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)�commentr%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

)rirr r%rr.r�r��writerL�getvalue)rrnr-r��outputZ	delimiterZ
expect_stringrrr	�
test_write�s(






zBasicTestCase.test_writecCs�|�dj|jdd��}Gdd�dt�}|�ddd�|�dd|d��|�dd	d�|�dd	|d��|�ddd�|�dd	d�dS)
Nz[sect]
option1{eq}foo
r)rfc@seZdZdS)z2BasicTestCase.test_set_string_types.<locals>.mystrN)rrrrrrr	�mystr�sr��sect�option1Zsplat�option2)r.rirr�r�)rr-r�rrr	�test_set_string_types�sz#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)	Nrrzincompatible formatzcfgparser.1znonexistent-filezFoo Barr8�newbar)
r�skipTestrr�r*�readrLrP�pathlibZPath)rZfile1r-�parsed_filesrrr	�test_read_returns_file_list�s2



z)BasicTestCase.test_read_returns_file_listcCs�|jddkr|�d�t�d���}|��}|�|�}|�||g�|��}|�d�}|�|g�|��}|�|dg�}|�||g�dS)Nrrzincompatible formatzcfgparser.1snonexistent-file)rr�rr��encoder*r�rL)rZfile1_bytestringr-r�rrr	�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
r)r�)r.rir)rrrr	�get_interpolation_config�sz&BasicTestCase.get_interpolation_configc	Csj|jd�|j�ddid�}t|jdddid��}|��|�||�|�tj	��|�d�WdQRXdS)	Nz�
            [section]
            name {0[0]} %(value)s
            key{0[1]} |%(name)s|
            getdefault{0[1]} |%(default)s|
        �defaultz	<default>)rr:r>)rDzno such section)
r.rirrMrrJrLrUr/rV)rr�r-rerrr	�check_items_configsz BasicTestCase.check_items_configc	Csx|jd�|j�ddid�}|�|��dd�|�|��dd�|�|��dd�|�t��|��WdQRXdS)	Nz�
            [section1]
            name1 {0[0]} value1
            [section2]
            name2 {0[0]} value2
            [section3]
            name3 {0[0]} value3
        r�z	<default>)rr�section1�section2�section3)r.rirrL�popitemrUr[)rr-rrr	�test_popitem!szBasicTestCase.test_popitemcCs�|�ddi�}|�|�|jd�dd�ddd�|d<|�|��dg�|�t|d���d	d
dh�|��|�t|���t��|�t||j���dh�dS)Nr8r�r�z@could not locate option, expecting case-insensitive option names�value1rr)r�r�Zzingr�r�)r*rLrPr%rKr�r
�clear)rr-rrr	�
test_clear0szBasicTestCase.test_clearcCs�|jd�|j�ddid�}|�t|d���ddh�|�t|d���d	dh�|�t|d
���ddh�|�|ddd�|�|dd	d
�|�|d
dd�|�|��ddd
g�ddi|d<|�t|d���ddh�|�|ddd�|�d	|d�|�|��ddd
g�i|d
<|�t|d
���dh�|�d|d
�|�|��ddd
g�i||j<|�t||j���t��|�t|d���dh�|�t|d���dh�|�t|d
���t��|�|��ddd
g�dS)Nz�
            [section1]
            name1 {0[0]} value1
            [section2]
            name2 {0[0]} value2
            [section3]
            name3 {0[0]} value3
        ZnameDZvalueD)rr�Zname1Znamedr�Zname2r�Zname3r�rrZvalue3Zname22Zvalue22)	r.rirrLr�r
rK�assertNotInr%)rr-rrr	�test_setitem<s0
zBasicTestCase.test_setitemc	Cs||jr|�d�t�d�|jd��}|��}|�tj	��|�
|�WdQRX|�|�dd�d�|�|ddd�dS)Nz2if no_value is allowed, ParsingError is not raisedzC            [DEFAULT]
            test {0} test
            invalidrZDEFAULT�test)
rr�rkrlrirr*rUr/r�r+rLrP)rZinvalidr-rrr	�test_invalid_multiline_value\s
z*BasicTestCase.test_invalid_multiline_valueN)rrrrhrorwr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrr	r2Es._AI*(
		6!
 r2c@seZdZejZdZdS)�StrictTestCaseTN)rrrr/�RawConfigParserr(r$rrrr	r�lsr�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)r�r�z5something %(with11)s lots of interpolation (11 steps))r�rLrPr�r/�InterpolationDepthErrorr&r1ra�
isinstance�LegacyInterpolation)rr-rfr�rrr	�test_interpolationtsz'ConfigParserTestCase.test_interpolationcCs�|��}|�|tjdd�}|�|jd�|�|jd�|�|jd�|jtj	kr`|�|j
d�nt|jtj�r||�|j
d�dS)NzInterpolation ErrorrO�	reference)rOzInterpolation Errorz
%(reference)sr�)
r�r�r/�InterpolationMissingOptionErrorrLr�r:rsr&r1rar�r�)rr-r�rrr	� test_interpolation_missing_value�s
z5ConfigParserTestCase.test_interpolation_missing_valuecCs|�dddddg�dS)N)r�z	<default>)�
getdefaultz|<default>|)rqz|value|)rOr>)r>r>)r�)rrrr	�
test_items�s
zConfigParserTestCase.test_itemsc	Cs�|�dj|jdd��}|�|�dd�d�|jtjkrN|�|�dd�d�n0t|jtj	�r~|�
t��|�dd�WdQRXdS)	Nzc[section]
option1{eq}xxx
option2{eq}%(option1)s/xxx
ok{eq}%(option1)s/%%s
not_ok{eq}%(option2)s/%%sr)rfr:�okzxxx/%sZnot_okz
xxx/xxx/%s)r.rirrLrPr&r/r1r�r�rU�	TypeError)rr-rrr	�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)
Nz[sect]
option1{eq}foo
r)rfr�r�r8z%foozfoo%zf%oor�zfoo%%barzfoo%bar)r.rirrLrPrUrbr�)rr-rrr	�#test_set_malformatted_interpolation�sz8ConfigParserTestCase.test_set_malformatted_interpolationcCs�|�dj|jdd��}|�t|jddd�|�t|jddd�|�t|jddt��|�t|jddd�|�t|jddd�|�t|jddt��|�t|jdd	d
�|�t|jd	�dS)Nz[sect]
option1{eq}foo
r)rfr�r�rg�?r�rpzinvalid opt name!)r.rirrUr�r��objectr)rr-rrr	�test_set_nonstring_types�sz-ConfigParserTestCase.test_set_nonstring_typescCs|��}|�t|j|j�dS)N)r*rUrbrr%)rr-rrr	�test_add_section_default�sz-ConfigParserTestCase.test_add_section_defaultcCs�|jddid�}|�||jdd�|�||j�d�d�|jddid�}|�||jdd	�|�||j�d�d�dS)
Nrg333333@)rrGz2.4rxg������@ryz5.2)r*rLr%rRrS)rr-rrr	�test_defaults_keyword�sz*ConfigParserTestCase.test_defaults_keywordN)rrrr/�ConfigParserr(r�r�r�r�r�r�r�r�rrrr	r�qsr�c@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�onerG�twoz%(one)s * 2�threez${common:one} * 3ZhexenZsixteenz${numbers:two} * 8)rL)rr-rrr	�assertMatchesIni�sz4ConfigParserTestCaseNoInterpolation.assertMatchesInicCs|�|j�}|�|�dS)N)r.�inir�)rr-rrr	�test_no_interpolation�sz9ConfigParserTestCaseNoInterpolation.test_no_interpolationcCs|��}|�|�d��dS)N�)r*�assertIsNoner+)rr-rrr	�test_empty_case�sz3ConfigParserTestCaseNoInterpolation.test_empty_casecCs2Gdd�dtj�}|�}|�|j�|�|�dS)Nc@seZdZdZdS)zbConfigParserTestCaseNoInterpolation.test_none_as_default_interpolation.<locals>.CustomConfigParserN)rrrZ_DEFAULT_INTERPOLATIONrrrr	�CustomConfigParser�sr�)r/r�r+r�r�)rr�r-rrr	�"test_none_as_default_interpolation�szFConfigParserTestCaseNoInterpolation.test_none_as_default_interpolation)rrrr/r�r(r&rkrl�stripr�r�r�r�r�rrrr	r��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)Nz[sect]
option1{eq}foo
r)rfr�r�r8z%foozfoo%zf%oor�zfoo%%bar)r.rirrLrPr�)rr-rrr	r��szKConfigParserTestCaseLegacyInterpolation.test_set_malformatted_interpolationN)	rrrr/r�r(r�r&r�rrrr	r��sr�c@seZdZdZdZdZdS)�)ConfigParserTestCaseNonStandardDelimiters)z:=�$)z//�"N)rrrrr r!rrrr	r�sr�c@seZdZdZdS)�-ConfigParserTestCaseNonStandardDefaultSectionZgeneralN)rrrr%rrrr	r�sr�c@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!� z	
c	Cs||��}xLtd�D]@}d�|�}|�|�x&td�D]}|�|d�|�|j�q4WqWttjd��}|�	|�WdQRXdS)N�dz	section{}�
z
lovely_spam{}�w)
r*r�rirr��wonderful_spamr�r�TESTFNr�)rr-r
�s�jr�rrr	�setUps

zMultilineValuesTestCase.setUpcCst�tj�dS)N)�os�unlinkrr�)rrrr	�tearDown(sz MultilineValuesTestCase.tearDownc	CsJ|��}ttj��}|�|�WdQRX|�|�dd�|j�dd��dS)NZsection8Zlovely_spam4z	
�
)	r*r�rr�r�rLrPr��replace)rZcf_from_filer�rrr	� test_dominating_multiline_values+s
z8MultilineValuesTestCase.test_dominating_multiline_valuesN)rrrr/r�r(rr�r�rrrrrr	r�s
r�c@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)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-rfrrr	r�8sz*RawConfigParserTestCase.test_interpolationcCs|�dddddg�dS)N)r�z	<default>)r�z
|%(default)s|)rqz
|%(name)s|)rOz	%(value)s)r>r>)r�)rrrr	r�Ds
z"RawConfigParserTestCase.test_itemscCs
|��}|�d�|�ddd�|�ddddddddd	d
g�|�dddd
i�|�|�dd�d�|�|�dd�ddddddd	d
g�|�|�dd�dd
i�|�d�|�ddd�|�|�dd�d�|jtjk�rdd�|_|�ddd�|�|�dd�d�dS)Nz
non-stringr?rrMr��r���
r'Zpign��!	@rpzthis is sickTcSs|S)Nr)r�rrr	�<lambda>[�zBRawConfigParserTestCase.test_set_nonstring_types.<locals>.<lambda>)	r*rr�rLrPZ_dictr/r0�optionxform)rr-rrr	r�Ks 


z0RawConfigParserTestCase.test_set_nonstring_typesc	Csf|�t��}|jddid�WdQRX|j}|�t|�d�|jddid�}|�||jdd�dS)Nrg333333@)rz%'int' object has no attribute 'lower'rxg������@ry)rUrZr*r`rLr�rRr%)rZctx�errr-rrr	r�_sz-RawConfigParserTestCase.test_defaults_keywordN)
rrrr/r�r(r�r�r�r�rrrr	r5s
rc@seZdZdZdZdZdS)�,RawConfigParserTestCaseNonStandardDelimiters)z:=r�)z//r�N)rrrrr r!rrrr	r
isr
c@s&eZdZejZdZdZdZdd�Z	dS)�RawConfigParserTestSambaConf)rrz----)z//FcCs�t�d�}|��}|j|dgdd�}|�||g�ddddd	d
dg}|�|��|�|�|�dd�d
�|�|�dd�d�|�|�dd�d�|�|�d
d�d�dS)Nzcfgparser.2znonexistent-filezutf-8)r��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_readingus
z)RawConfigParserTestSambaConf.test_readingN)
rrrr/r�r(r r!r"rrrrr	ros
rc@s\eZdZejZe��ZdZdZ	ddd�Z
dd�Zdd	�Zd
d�Z
dd
�Zdd�Zdd�ZdS)�)ConfigParserTestCaseExtendedInterpolation�commonTNcCs"|�|�}|r||_|�|�|S)N)r*rr+)rr,rrr-rrr	r.�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}
        rzfavourite 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.rkrlr�rL)rr-rfrrr	�test_extended_interpolation�s*zEConfigParserTestCaseExtendedInterpolation.test_extended_interpolationc	Cs`|�t�d����}|�tj��|ddWdQRX|�tj��|ddWdQRXdS)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.rkrlr�rUr/r�)rr-rrr	�test_endless_loop�s	z;ConfigParserTestCaseExtendedInterpolation.test_endless_loopc	Cs�|�d�}|�|ddd�|�|ddd�|�|ddd�tj}|�|��}|dd	WdQRX|�|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:${sickrz${dollars:${sick}})r.rLr/r�rUr`r�ra)rr-Zexception_classrgrrr	�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
        rZoptionlowerr>ZOptionUpper�Value�Commonza better valuezA Better Value�randomZfoolowerzvalue redefinedZFooUpperzA Better Value Redefined)rkrlr�r.rL)rr�r-rfrrr	�test_case_sensitivity_basic�s

zEConfigParserTestCaseExtendedInterpolation.test_case_sensitivity_basicc	Cs�t�d���}|�tj��|�|�}WdQRX|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|S)Nr)r�rrr	r	
r
z[ConfigParserTestCaseExtendedInterpolation.test_case_sensitivity_conflicts.<locals>.<lambda>)rrrsr>r}rrza better valuezA Better Valuerr8zvalue redefinedr�zA Better Value Redefined)rkrlr�rUr/rjr.rL)rr�r-rfrrr	�test_case_sensitivity_conflicts�s
zIConfigParserTestCaseExtendedInterpolation.test_case_sensitivity_conflictsc	Cs�|�d�}|�tj��|ddWdQRX|�tj��|ddWdQRX|�tj��|ddWdQRX|�tj��|ddWdQRX|�tj��|ddWdQRX|�t��d|dd	<WdQRXdS)
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.rUr/�InterpolationSyntaxErrorr�rb)rr-rrr	�test_other_errorssz;ConfigParserTestCaseExtendedInterpolation.test_other_errors)NN)rrrr/r�r(�ExtendedInterpolationr&r%r$r.rrrrrrrrrr	r�s
-rc@seZdZdZdS)�ConfigParserTestCaseNoValueTN)rrrrrrrr	r .sr c@s2eZdZejZdhZdhZdZdd�Z	dd�Z
dS)	�ConfigParserTestCaseTrickyFilerrTc
Cs|t�d�}|��}|�t|j|dd��d�|�|��ddddd	d
dg�|�|j|jdd
did�d�|�	t
��|j|jddd
did�WdQRX|�t|�dd��d��d�|�t|�dd��d��d�d}|�
|�|d��|�|�|d�d�|�t|�d��d�|�	tj��|�d	�WdQRX|�|�d
d�d�|�|�d
d�|�d
d��|�|�dd�d�dS)Nzcfgparser.3zutf-8)r�rZstrangeZ
corruptionz&yeah, sections can be indented as wellzanother one!zno values hereztricky interpolationzmore interpolationZgoZinterpolatez-1)rD���T)�rawrD�otherr�r>r�zare they subsectionszlets use some Unicodeu	片仮名r�Zletszdo thiszgo shopping)rr�r*rLrNr�rKrQr%rUrbrP�splitr]rTrr/r�)rr�r-Zlongnamerrr	�test_cfgparser_dot_38s6
z3ConfigParserTestCaseTrickyFile.test_cfgparser_dot_3c	Cs:t�d�}|��}|�t��|j|dd�WdQRXdS)Nzcfgparser.3�ascii)r�)rr�r*rU�UnicodeDecodeErrorr�)rr�r-rrr	�test_unicode_failureXs
z3ConfigParserTestCaseTrickyFile.test_unicode_failureN)rrrr/r�r(rr rr'r*rrrr	r!2s r!c@s(eZdZdZdd�Zdd�Zdd�ZdS)	�Issue7005TestCasez[section]
option = None

cCs<|dd�}|�d�|�ddd�t��}|�|�|��S)NF)rr:rs)rr�r�r�r�r�)rr(�cpr�rrr	�preparehs


zIssue7005TestCase.preparec	Cs>tjdd�}|�d�|�t��|�ddd�WdQRXdS)NF)rr:rs)r/r�rrUr�r�)rr,rrr	�test_none_as_value_stringifiedqs
z0Issue7005TestCase.test_none_as_value_stringifiedcCs|�tj�}|�||j�dS)N)r-r/r�rL�expected_output)rr�rrr	�"test_none_as_value_stringified_rawwsz4Issue7005TestCase.test_none_as_value_stringified_rawN)rrrr/r-r.r0rrrr	r+_s	r+c@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

)r.r�r�r�rLr�)rr-r�rrr	�test_sorteds



zSortedTestCase.test_sortedN)rrrrr#r2rrrr	r1|sr1c@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
        z
Commented Barr8zbar # not a comment!r6r7Zquirkzthis;is not a comment)rkrlr.rLrP)rrnr-rrr	�test_comment_handling�s
z(CompatibleTestCase.test_comment_handlingN)	rrrr/r�r(r r!r4rrrr	r3�sr3c@seZdZejZddd�ZdS)�CopyTestCaseNcCsx|�|�}|�|�|��}|�|�xL|��D]@}|j|jkrBq0x,||j��D]\}}|||krR||=qRWq0W|S)N)r*r+rurrOr%r)rr,rr-Zcf_copyr:r�r>rrr	r.�s


zCopyTestCase.fromstring)N)rrrr/r�r(r.rrrr	r5�sr5c@seZdZdd�Zdd�ZdS)�FakeFilec	Cs6t�d�}t|��}|��|_|j��WdQRXdS)Nzcfgparser.1)rr�r��	readlines�lines�reverse)r�	file_pathr�rrr	�__init__�s


zFakeFile.__init__cCst|j�r|j��SdS)Nr�)rNr8�pop)rrrr	r��s

zFakeFile.readlineN)rrrr;r�rrrr	r6�sr6ccs$|��}x|r|V|��}q
WdS)N)r�)r��linerrr	�readline_generator�sr>c@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�ReadFileTestCasec
Cs�t�d�g}y|�|d�d��Wntk
r8YnXxb|D]Z}t��}t|��}|�|�WdQRX|�	d|�|�	d|d�|�
|ddd�q@WdS)Nzcfgparser.1r�utf8zFoo Barr8r�)rr�rIr��UnicodeEncodeErrorr/r�r�r��assertInrL)rZ
file_pathsr:rYr�rrr	�	test_file�s

zReadFileTestCase.test_filecCsZt�d����d�}t��}|�|�|�d|�|�d|d�|�|ddd�dS)Nz%
        [Foo Bar]
        foo=newbarrzFoo Barr8r�)	rkrlr�r&r/r�r�rBrL)rr8rYrrr	�
test_iterable�s
zReadFileTestCase.test_iterablec	Csnt��}|�t��|�t��WdQRX|�tt���|�d|�|�d|d�|�|ddd�dS)NzFoo Barr8r�)	r/r�rUr�r�r6r>rBrL)rrYrrr	�test_readline_generator�sz(ReadFileTestCase.test_readline_generatorc	CsTt�d����d�}t��}|�tj��}|j|dd�WdQRX|�	t
|j�d�t�d����d�}t��}|�tj��}|j|dd�WdQRX|�	t
|j�d�t�d����d�}t��}|�tj
��}|j|dd�WdQRX|�	t
|j�d	�t�d
����d�}t��}|�tj��}|j|dd�WdQRX|�	t
|j�d�dS)Nz"
        [badbad]
        [badbad]rsbadbad)r�zGWhile 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')rkrlr�r&r/r�rUrmr�rLr�r`rjr�r�)rr8rYZdserrr	�test_source_as_bytes�s@z%ReadFileTestCase.test_source_as_bytesN)rrrrCrDrErFrrrr	r?�s

r?c@sLeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dS)�CoverageOneHundredTestCasecCsft�dd�}|�|jd�|�|jd�|�|jd�|�|jd�|�|jd�|�t|�d�dS)Nr:rs)r:rsNNz3Option 'option' in section 'section' already exists)	r/rjrLr:rsr��linenorar�)rr�rrr	�test_duplicate_option_error'sz6CoverageOneHundredTestCase.test_duplicate_option_errorcCs<t�ddd�}|�|jd�|�|jd�|�|jd�dS)Nrsr:�rawval)rsr:rJ)r/r�rLrarsr:)rr�rrr	�test_interpolation_depth_error1s
z9CoverageOneHundredTestCase.test_interpolation_depth_errorc	Cs�|�t��}t��WdQRX|�t|j�d�|�t��}tjddd�WdQRX|�t|j�d�tjdd�}|�|jd�tj	dd��4}t�
d	t�|�|jd�d|_|�|jd�WdQRXx|D]}|�
|jtk�q�WdS)
Nz%Required argument `source' not given.r��filename)r�rLz:Cannot specify both `filename' and `source'. Use `source'.)rLT)�record�always)rUrbr/r�rLr�r`r��warnings�catch_warnings�simplefilter�DeprecationWarningrLr\�category)rrgr�r��warningrrr	�test_parsing_error8s
z-CoverageOneHundredTestCase.test_parsing_errorc	Cs�t��}|�d�|�tj��}|ddWdQRX|�t|j�d�|�tj��}|ddWdQRX|�t|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+rUrrLr�r`)rrYrgrrr	�test_interpolation_validationKsz8CoverageOneHundredTestCase.test_interpolation_validationc	Cs�t�d�}t��}tjdd�� }t�dt�|j|dd�WdQRXx|D]}|�	|j
tk�qJW|�t|�d�|�|dd	d
�dS)Nz2
        [section]
        option = value
        T)rMrNr�)rLrr:rsr>)
r�r�r/r�rOrPrQrRZreadfpr\rSrLrN)rr�rYr�rTrrr	�test_readfp_deprecation\s
z2CoverageOneHundredTestCase.test_readfp_deprecationc	CsNtjdd��}t�dt�t��}WdQRXx|D]}|�|jtk�q2WdS)NT)rMrN)rOrPrQrRr/ZSafeConfigParserr\rS)rr�rYrTrrr	�!test_safeconfigparser_deprecationjs

z<CoverageOneHundredTestCase.test_safeconfigparser_deprecationcCs*t��}|�d�|�t|d�d�dS)Nz7
            [section]
            key = value
        r:z<Section: section>)r/r�r+rL�repr)rrYrrr	�test_sectionproxy_reprqsz1CoverageOneHundredTestCase.test_sectionproxy_reprc	Cs@t��}ddl}|j|jd<|�d�|�d|j�|�|�dd�d�|�|�dd�d	�|�|d�d�d�|�|d�d�d	�|`|�	t
��|�dd�WdQRX|�d|j�|jd=|�d|j�|�	t
��|�dd�WdQRX|�	t
��|d�d�WdQRX|�	t
��|d�d�WdQRXdS)
Nr�decimalzS
            [s1]
            one = 1
            [s2]
            two = 2
        �s1r�r�s2r�r)r/r�r[�Decimal�
convertersr+rBrL�
getdecimalrUrZr�)rrYr[rrr	�"test_inconsistent_converters_stateys,z=CoverageOneHundredTestCase.test_inconsistent_converters_stateN)rrrrIrKrUrVrWrXrZrarrrr	rG$s
rGc@sdeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dS)�ExceptionPicklingTestCasecCshddl}t�d�}xPt|jd�D]>}|�||�}|�|�}|�|j|j�|�t	|�t	|��q"WdS)Nrr>r)
�pickler/�Errorr��HIGHEST_PROTOCOL�dumps�loadsrL�messagerY)rrc�e1�proto�pickled�e2rrr	�
test_error�s

z$ExceptionPicklingTestCase.test_errorcCs�ddl}t�d�}xpt|jd�D]^}|�||�}|�|�}|�|j|j�|�|j	|j	�|�|j
|j
�|�t|�t|��q"WdS)Nrr:r)rcr/rVr�rerfrgrLrhrar:rY)rrcrirjrkrlrrr	�test_nosectionerror�s

z-ExceptionPicklingTestCase.test_nosectionerrorcCs�ddl}t�dd�}x�t|jd�D]n}|�||�}|�|�}|�|j|j�|�|j	|j	�|�|j
|j
�|�|j|j�|�t|�t|��q$WdS)Nrrsr:r)
rcr/rWr�rerfrgrLrhrar:rsrY)rrcrirjrkrlrrr	�test_nooptionerror�s
z,ExceptionPicklingTestCase.test_nooptionerrorcCs�ddl}t�ddd�}x�t|jd�D]~}|�||�}|�|�}|�|j|j�|�|j	|j	�|�|j
|j
�|�|j|j�|�|j|j�|�t
|�t
|��q&WdS)Nrr:r�rpr)rcr/rmr�rerfrgrLrhrar:r�rHrY)rrcrirjrkrlrrr	�test_duplicatesectionerror�s
z4ExceptionPicklingTestCase.test_duplicatesectionerrorcCs�ddl}t�dddd�}x�t|jd�D]�}|�||�}|�|�}|�|j|j�|�|j	|j	�|�|j
|j
�|�|j|j�|�|j|j�|�|j
|j
�|�t|�t|��q(WdS)Nrr:rsr�rpr)rcr/rjr�rerfrgrLrhrar:rsr�rHrY)rrcrirjrkrlrrr	�test_duplicateoptionerror�s

z3ExceptionPicklingTestCase.test_duplicateoptionerrorcCs�ddl}t�ddd�}x�t|jd�D]n}|�||�}|�|�}|�|j|j�|�|j	|j	�|�|j
|j
�|�|j|j�|�t|�t|��q&WdS)Nrrsr:�msgr)
rcr/ZInterpolationErrorr�rerfrgrLrhrar:rsrY)rrcrirjrkrlrrr	�test_interpolationerror�s
z1ExceptionPicklingTestCase.test_interpolationerrorcCs�ddl}t�dddd�}x�t|jd�D]~}|�||�}|�|�}|�|j|j�|�|j	|j	�|�|j
|j
�|�|j|j�|�|j|j�|�t
|�t
|��q(WdS)Nrrsr:rJr�r)rcr/r�r�rerfrgrLrhrar:rsr�rY)rrcrirjrkrlrrr	�$test_interpolationmissingoptionerror�s
z>ExceptionPicklingTestCase.test_interpolationmissingoptionerrorcCs�ddl}t�ddd�}x�t|jd�D]n}|�||�}|�|�}|�|j|j�|�|j	|j	�|�|j
|j
�|�|j|j�|�t|�t|��q&WdS)Nrrsr:rrr)
rcr/rr�rerfrgrLrhrar:rsrY)rrcrirjrkrlrrr	�test_interpolationsyntaxerror�s
z7ExceptionPicklingTestCase.test_interpolationsyntaxerrorcCs�ddl}t�ddd�}x�t|jd�D]n}|�||�}|�|�}|�|j|j�|�|j	|j	�|�|j
|j
�|�|j|j�|�t|�t|��q&WdS)Nrrsr:rJr)
rcr/r�r�rerfrgrLrhrar:rsrY)rrcrirjrkrlrrr	�test_interpolationdeptherror�s
z6ExceptionPicklingTestCase.test_interpolationdeptherrorcCsnddl}t�d�}|�dd�|�dd�|�dd�x�t|jd�D]n}|�||�}|�|�}|�|j	|j	�|�|j
|j
�|�|j|j�|�|j|j�|�t
|�t
|��qFWtjd	d
�}|�dd�|�dd�|�dd�x�t|jd�D]n}|�||�}|�|�}|�|j	|j	�|�|j
|j
�|�|j|j�|�|j|j�|�t
|�t
|��q�WdS)Nrr�rZline1rZline2rZline3rL)rL)rcr/r�rIr�rerfrgrLrhrar��errorsrY)rrcrirjrkrlrrr	�test_parsingerrors2


z+ExceptionPicklingTestCase.test_parsingerrorcCs�ddl}t�ddd�}x�t|jd�D]~}|�||�}|�|�}|�|j|j�|�|j	|j	�|�|j
|j
�|�|j|j�|�|j|j�|�t
|�t
|��q&WdS)NrrLrpr=r)rcr/r�r�rerfrgrLrhrar=r�rHrY)rrcrirjrkrlrrr	�test_missingsectionheadererror#s
z8ExceptionPicklingTestCase.test_missingsectionheadererrorN)rrrrmrnrorprqrsrtrurvrxryrrrr	rb�s	

rbc@seZdZdd�ZdS)�InlineCommentStrippingTestCasecCs�tjdd�}|�d�|d}|�|dd�|�|dd�|�|d	d
�|�|dd�|�|d
d�|�|dd�|�|dd�|d}|�|dd�|�|dd�|�|d	d�dS)N)rrz//)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:Zk1zv1;still v1Zk2Zv2Zk3Zv3Zk4zv4;still v4Zk5zv5;still v5Zk6zv6;still v6; and still v6Zk7zv7;still v7; and still v7Zmultiprefixzv3;#//still v3# and still v3)r/r�r+rL)r�cfgr�rrr	�test_stripping5sz-InlineCommentStrippingTestCase.test_strippingN)rrrr|rrrr	rz1srzc@s4eZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)�ExceptionContextTestCasec	CsNt��}|�d�|�tj�}|�|�dd�WdQRX|�|jjd�dS)Nz�
        [Paths]
        home_dir: /Users
        my_dir: %(home_dir1)s/lumberjack
        my_pictures: %(my_dir)s/Pictures
        �Paths�my_dirT)	r/r�r+rUr�rPrXr`�__suppress_context__)rrYrgrrr	�test_get_basic_interpolationYsz5ExceptionContextTestCase.test_get_basic_interpolationc	CsVtjt��d�}|�d�|�tj�}|�|�dd�WdQRX|�|jj	d�dS)N)r&z�
        [Paths]
        home_dir: /Users
        my_dir: ${home_dir1}/lumberjack
        my_pictures: ${my_dir}/Pictures
        r~rT)
r/r�rr+rUr�rPrXr`r�)rrYrgrrr	�test_get_extended_interpolationfsz8ExceptionContextTestCase.test_get_extended_interpolationc	CsHt��}|�d�|�tj��}|�d�WdQRX|�|jjd�dS)Nz2
        [Paths]
        home_dir: /Users
        r�T)	r/r�r+rUrVr�rXr`r�)rrYrgrrr	�test_missing_optionstsz-ExceptionContextTestCase.test_missing_optionsc	CsBt��}|�tj��}|�ddd�WdQRX|�|jjd�dS)N�Section1�an_intZ15T)r/r�rUrVr�rXr`r�)rrvrgrrr	�test_missing_section~sz-ExceptionContextTestCase.test_missing_sectionc	Cs@t��}|�tj��}|�dd�WdQRX|�|jjd�dS)Nr�r�T)r/r�rUrVr_rXr`r�)rrvrgrrr	�test_remove_option�sz+ExceptionContextTestCase.test_remove_optionN)rrrr�r�r�r�r�rrrr	r}Us


r}cs,eZdZejZd�fdd�	Zdd�Z�ZS)�ConvertersTestCaseNcs t�j|d�}dd�|jd<|S)N)rcSsdd�|��D�S)NcSsg|]}|��r|���qSr)r�)rr�rrr	r�szBConvertersTestCase.newconfig.<locals>.<lambda>.<locals>.<listcomp>)r&)�vrrr	r	�r
z.ConvertersTestCase.newconfig.<locals>.<lambda>rM)�superr*r_)rrr))�	__class__rr	r*�szConvertersTestCase.newconfigc
Cs�|��}|�d|j�|�d|j�|�|jd�|�|jd�|�|jd�|�|jd�|�t|j�d�|�t��dd�|jd<WdQRX|�t��d	d�|jd<WdQRX|�	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�dddddddg�|�|�dd�d�|�|�
d�d
�|�|�d�d�|�|�d�d�|�|�
d�dddddddg�|�|�d�d�|�t��|�dd�WdQRX|�t��|�d�WdQRXddl}|j|jd<|�d|j�|�|jd�|�t|j�d�|�d�}|�|�dd�|�|�|�d�|�|jd=|�d|j�|�t|j�d�|�t��|�dd�WdQRX|�t��|�d�WdQRX|�t��|jd=WdQRX|�t��|jd=WdQRX|�t��|jd=WdQRXdS) NrBrMr?rAr%cSs|S)Nr)r�rrr	r	�r
z4ConvertersTestCase.test_converters.<locals>.<lambda>r�cSs|S)Nr)r�rrr	r	�r
z~
        [s]
        str = string
        int = 1
        float = 0.5
        list = a b c d e f g
        bool = yes
        r�r�r,rGz0.5z
a b c d e f g�boolrFrg�?ryr{�c�dr�r��gTrr[r�)r*rBr_r��assertIsNotNonerLrNrUrbr+rPrQrSZgetlistrTrZr`r[r^r�r[)rr{r�r[Zdec0_5rrr	�test_converters�s|
z"ConvertersTestCase.test_converters)N)	rrrr/r�r(r*r��
__classcell__rr)r�r	r��sr�c@s0eZdZdZdd�Zdd�Zdd�Zdd	�Zd
S)�!BlatantOverrideConvertersTestCasez�
        [one]
        one = false
        two = false
        three = long story short

        [two]
        one = false
        two = false
        three = four
    cCs:tjdtid�}|�|j�|�|�|�|jd�dS)NrN)r_)r/r�rNr+rv�	_test_lenr�r_)rr{rrr	�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)r#rDrCcs"||krdSt�j|||||d�S)NT)r#rDrC)r�rT)rr:rsr#rDrC)r�rr	rT�szZBlatantOverrideConvertersTestCase.test_inheritance.<locals>.StrangeConfigParser.getbooleancSs|j||t|||d�S)N)r#rDrC)Z	_get_convrN)rr:rsr#rDrCrrr	�getlen�szVBlatantOverrideConvertersTestCase.test_inheritance.<locals>.StrangeConfigParser.getlen)	rrrZ
gettysburgr/r1rTr�r�rr)r�r	�StrangeConfigParser�s
r�rNr�r�rB)r/r�r+rvr�r�r_r\rTr]�_convert_to_boolean)rr�r{rrr	�test_inheritance�s
z2BlatantOverrideConvertersTestCase.test_inheritancec	Cs�|�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�WdQRX|�|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)Nr%rBrNZtysburgr?rAr�r�r�r��Zfourr)rC)
rLrNr_rBr�r�r�rUr/rW)rr{rrr	r�s0z+BlatantOverrideConvertersTestCase._test_lenc	s�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�WdQRX|�t��|��d
�d	�d�WdQRXdS)NcSsdS)NTr)r:rsrrr	r	,r
zLBlatantOverrideConvertersTestCase.test_instance_assignment.<locals>.<lambda>cst�||�S)N)rN)r:rs)r{rr	r	-r
rrBrNr?rAr�r�r�r�r�r%)r/r�rTr�r+rvrLrNr_rBr�r�r\r�r]rUrZ)rr)r{r	�test_instance_assignment*s:
 z:BlatantOverrideConvertersTestCase.test_instance_assignmentN)rrrrvr�r�r�r�rrrr	r��s
r�c@seZdZdd�ZdS)�MiscTestCasecCsdh}tj|t|d�dS)Nrd)�	blacklist)rZcheck__all__r/)rr�rrr	�test__all__MszMiscTestCase.test__all__N)rrrr�rrrr	r�Lsr��__main__),�collectionsr/r�r�r�rkZunittestrOr�r�UserDictrrr2ZTestCaser�r�r�r�r�r�r�rr
rrr r!r+r1r3r5r6r>r?rGrbrzr}r�r�r�r�mainrrrr	�<module>s`!-c$4,-
Sr$6Ro