403Webshell
Server IP : 118.27.122.248  /  Your IP : 216.73.217.130
Web Server : Apache
System : Linux web0264.sh.tyo1 4.18.0-553.79.1.lve.el7h.x86_64 #1 SMP Wed Oct 15 16:34:46 UTC 2025 x86_64
User : c9415830 ( 11735)
PHP Version : 8.4.17
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /opt/alt/python36/lib64/python3.6/test/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /opt/alt/python36/lib64/python3.6/test/__pycache__/test_configparser.cpython-36.opt-1.pyc
3

�w2_L�@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�rpej+�dS)@�N)�supportc@s@eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�ZeZ	d
S)�
SortedDictcCst|jj��S)N)�sorted�data�items)�self�r�;/opt/alt/python36/lib64/python3.6/test/test_configparser.pyrszSortedDict.itemscCst|jj��S)N)rr�keys)rrrr	r
szSortedDict.keyscCsdd�|j�D�S)NcSsg|]}|d�qS)�r)�.0�irrr	�
<listcomp>sz%SortedDict.values.<locals>.<listcomp>)r)rrrr	�valuesszSortedDict.valuescCst|j��S)N)�iterr)rrrr	�	iteritemsszSortedDict.iteritemscCst|j��S)N)rr
)rrrr	�iterkeysszSortedDict.iterkeyscCst|j��S)N)rr)rrrr	�
itervaluesszSortedDict.itervaluesN)
�__name__�
__module__�__qualname__rr
rrrr�__iter__rrrr	r
src@sJeZdZdZdZd
ZdZdZej	Z
dZejZ
ejZddd	�Zdd
d�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|j|�}|j|�|S)N)r*�read_string)r�stringr�cfrrr	�
fromstring?s

z!CfgParserTestCaseClass.fromstring)rr)rr)rr)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+S),�
BasicTestCasec	�Cs�ddddddddd	g	}|jr&|jd
�|j�d>d?g}|j�}|j�|j}|||�|jd�}|j�|||�dd�|D�}|j�|j|j�|j�|||�|dj�}tt|��}|||�|j�}tt|��}|jt	|�t	|��x|D]\}}|||j
�q�W||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!�|j�r:||jd
d"�d�||jdd
dd#�d�||jdd
d
did$�d�|jtj��|jd%d
�WdQRX|jtj��|jdd&�WdQRX||jd%d
dd#�d�||jdd&dd#�d�||jdd
dd#�d�||jd'd
dd#�d�||j
d	dd(d#�d�||j
d	d)d(d#�d(�||j
d	d)d*d#�d*�|jtj��|j
d	d)�WdQRX|j|jd	dd+d#�d�|j|jd	d,d+d#�d+�||jd	d,d-d#�d-�|jtj��|jd	d,�WdQRX||jd	dd.d#�d�||jd	d/d0d#�d0�||jd	d/d.d#�d.�|jtj��|jd	d/�WdQRX||jd1dd.d#�d.�|j�r�||jd
d"dd#�d�||jd
d2dd#�d�||dd
d�||dd
d�|d}||j
d�|j|j|�|jt��d3|_
WdQRX|jt��d4|_WdQRX||d
d�||dd�||dd
d�||ddd�||ddd�||ddd�||dd
d5�|j�r�||d
d"d�||djd
d�d�||djd
dd#�d�||djd
d
did$�d�|jt��|d%d
WdQRX|jt��|dd&WdQRX|jt��|d%jd
dd#�WdQRX||djd&d�d�||djd&dd#�d�||djd&�d�||djd
d�d�||djd
dd#�d�|jt��|d'jd
d�WdQRX||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/d0d#�d0�||d	jd/d.�d.�||d	jd/d.d#�d.�||d	jd/�d�|j�	r*||d
jd"d�d�||d
jd"dd#�d�||d
jd2d�d�||d
jd2dd#�d�d6||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
�WdQRX|j|jjd@�||jdd
�d5�|d	=|jd	|k�|jt��|d	=WdQRX|jt ��||j=WdQRX|dd
=|jd
|dk�|jt��|dd
=WdQRX|jd9|dk�|jt��|dd9=WdQRX||jd9=|jd9|dk�|jt��||jd9=WdQRX|jt��|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>�bar1�bar2�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 removed�No Such Section)r6r7)r8r9)rI)!r�append�sort�sections�assertEqualrr%r�list�len�namer�get�getintZassertAlmostEqual�getfloat�
getboolean�assertRaisesr/�NoSectionError�
NoOptionError�assertIs�parser�AttributeError�KeyError�
assertTrueZremove_section�assertFalse�
has_option�
remove_option�	exception�args�
ValueError)	rr-�E�F�L�eqrPr:�cmrrr	�
basic_testGsz







zBasicTestCase.basic_testcCs�dj|j|j�}|jr|d7}|j|�}|j|�|jr�|jtj	��|j
tjdj|j���WdQRX|jtj
��|j
tjdj|j���WdQRXn0|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.rhr$rUr/�DuplicateOptionErrorr+�textwrap�dedent�DuplicateSectionError)r�
config_stringr-rrr	�
test_basic%s"

zBasicTestCase.test_basiccCsddiddiddd�ddd�ddiid	d
ddd
�ddd�ddddd�d�	}|jrb|jdddii�|j�}|j|�|j|�|jr�|jtj��|jddiddid��WdQRX|jtj	��|jdddd �i�WdQRXn,|jddiddid!��|jdddd �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�|j�}|jd�|jd�|jd�|j�}|j�|j}||dddg�|jddd�||jd�dg�||jdd�dd�|jt	j
��|jddd�WdQRX|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�ddid�}|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�	MySectionrs�Optionzfirst line
second linez[section]
nekey{}nevalue
rq)rr:�Key)r}r~rr|)r*�add_sectionrLrKrM�set�optionsrQrUr/rVr\r^r]r_r.rir)rr-rerf�optrrr	�test_case_sensitivity�sD






z#BasicTestCase.test_case_sensitivitycCs�|j�}i|d<ddi|d<i|d<dd�|D�}|j�|j}|j}||tdd|jdg��||dj�dh�||dddd�|jt��d|dd<WdQRX|j	d|dk�d	|dd
<x dD]}|j	||dkd�q�W||dj�dh�||dj�dh�|dd=||dj�i�|j
dj|jd��}||dj�dh�||ddd�|j
dj|jd�ddid�}|j	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 value�A-B�a-b�A-b�a-Bz9has_option() returned false for option which should existz3[MySection]
Option{} first line   
	second line   
rr�rsr�zfirst line
second linez[section]
nekey{}nevalue
rq)rr�r:)r�r�r�r�)
r*rKrMZassertCountEqualrr%r
rUr[r\r.rir)rr-rerfZelem_eqr�rrr	�$test_case_sensitivity_mapping_access�sB




z2BasicTestCase.test_case_sensitivity_mapping_accesscCsP|jddi�}|j|j|jd�dd�|jddi�}|j|j|jd�dd�dS)Nr8�Bar�Fooz@could not locate option, expecting case-insensitive option namesz<could not locate option, expecting case-insensitive defaults)r*rMrQr%)rr-rrr	�test_default_case_sensitivitysz+BasicTestCase.test_default_case_sensitivitycCs�|j�}|j|tjdj|jd��|j|tjdj|jd��|j|tjd�}|j|jd�|j	s�|j|tjd�}|j|jd
�t
jd�}|jddkr�tj}|f}ntj}|dd	f}t|d
d��}|j|||�}WdQRX|j|j|�dS)Nz[Foo]
{}val-without-opt-name
rr�No Section!
�<???>z[Foo]
  wrong-indent
zcfgparser.3rz.  # INI with as many tricky parts as possible
zutf-8)�encoding)r�rr�)r�)
r*�parse_errorr/�ParsingErrorrir�MissingSectionHeaderErrorrMrarr�findfile�open)rr-�e�tricky�error�expected�frrr	�test_parse_errorss0




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

zBasicTestCase.parse_errorcCs�|j�}|j|j�gd�|j|jd�d�|jtj��|jd�WdQRX|jtj��|j	ddd�WdQRX|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>)r8)r�r8)r*rMrLr]Zhas_sectionrUr/rVr�r��	get_errorrar�rW)rr-r�rrr	�test_query_errors0s
zBasicTestCase.test_query_errorscCsLy|j||�Wn |k
r0}z|Sd}~XnX|jd|j|jf�dS)Nzexpected exception type %s.%s)rQZfailrr)rr-r�r:rsr�rrr	r�AszBasicTestCase.get_errorcCsr|jdj|jdd��}xTtdd�D]F}|j|jdd|��|j|jdd|��|jt|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_booleancCs|j�}|jd�|jtj��}|jd�WdQRX|j}|jt|�d�|j|jd�|j	�r|jtj��(}|j
tjdj
|jdd��dd�WdQRX|j}|jt|�d�|j|jd�|jtj��}|jd
ddd
�i�WdQRX|j}|jt|�d�|j|jd�dS)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��	<foo-bar>)�sourcezFWhile reading from '<foo-bar>' [line  5]: section 'Foo' already existsr�r��valzis really `opt`)r��OPTzIWhile reading from '<dict>': option 'opt' in section 'Bar' already existsr��<dict>)r�NN)r�r�r�)r�r�r�N)r*r�rUr/rmr`rM�strrar$r+rkrlrirrjru)rr-rgr�rrr	�test_weird_errorscs&
$zBasicTestCase.test_weird_errorscCs�dj|j|jd|jd�}|jr(|d7}|j|�}xhdD]`}tj�}|j||d�|jd}|rjdj|�}d	j||jd
�}|jr�|d7}|j	|j
�|�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)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

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






zBasicTestCase.test_writecCs�|jdj|jdd��}Gdd�dt�}|jddd�|jdd|d��|jdd	d�|jdd	|d��|jddd�|jdd	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|jd�tjd�}|j�}|j|dg�}|j||g�|j|jdd�d�|j�}|j|�}|j||g�|j|jdd�d�|j�}|jtj	|��}|j||g�|j|jdd�d�|j�}|jtj	|�|g�}|j|||g�|j|jdd�d�|j�}|jdg�}|j|g�|j�}|jg�}|j|g�dS)	Nrrzincompatible formatzcfgparser.1znonexistent-filezFoo Barr8�newbar)
r�skipTestrr�r*�readrMrQ�pathlibZPath)rZfile1r-�parsed_filesrrr	�test_read_returns_file_list�s2



z)BasicTestCase.test_read_returns_file_listcCs|jdj|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|jdj|j�ddid�}t|jdddid��}|j�|j||�|jtj	��|jd�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.rirrNrrKrMrUr/rV)rr�r-rerrr	�check_items_configsz BasicTestCase.check_items_configc	Csx|jdj|j�ddid�}|j|j�dd�|j|j�dd�|j|j�dd�|jt��|j�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.rirrM�popitemrUr[)rr-rrr	�test_popitemszBasicTestCase.test_popitemcCs�|jddi�}|j|j|jd�dd�ddd�|d<|j|j�dg�|jt|dj��d	d
dh�|j�|jt|j��t��|jt||jj��dh�dS)Nr8r�r�z@could not locate option, expecting case-insensitive option names�value1rr)r�r�Zzingr�r�)r*rMrQr%rLr�r
�clear)rr-rrr	�
test_clearszBasicTestCase.test_clearcCs�|jdj|j�ddid�}|jt|dj��ddh�|jt|dj��d	dh�|jt|d
j��ddh�|j|ddd�|j|dd	d
�|j|d
dd�|j|j�ddd
g�ddi|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
        ZnameDZvalueD)rr�Zname1Znamedr�Zname2r�Zname3r�rrZvalue3Zname22Zvalue22)	r.rirrMr�r
rL�assertNotInr%)rr-rrr	�test_setitem+s0
zBasicTestCase.test_setitemcCs||jr|jd�tjdj|jd��}|j�}|jtj	��|j
|�WdQRX|j|jdd�d�|j|ddd�dS)Nz2if no_value is allowed, ParsingError is not raisedzC            [DEFAULT]
            test {0} test
            invalidrZDEFAULT�test)
rr�rkrlrirr*rUr/r�r+rMrQ)rZinvalidr-rrr	�test_invalid_multiline_valueKs
z*BasicTestCase.test_invalid_multiline_valueN)rrrrhrorwr�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�[sr�c@sJeZdZejZdd�Zdd�Zdd�Zdd�Z	d	d
�Z
dd�Zd
d�ZdS)�ConfigParserTestCasecCs�|j�}|j}||jdd�d�||jdd�d�||jdd�d�|j|tjdd�}|jtjkrr|j|jd
�nt	|jtj
�r�|j|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�5something %(with11)s lots of interpolation (11 steps))r�r�r�)r�r�r�)r�rMrQr�r/�InterpolationDepthErrorr&r1ra�
isinstance�LegacyInterpolation)rr-rfr�rrr	�test_interpolationcsz'ConfigParserTestCase.test_interpolationcCs�|j�}|j|tjdd�}|j|jd�|j|jd�|j|jd�|jtj	kr`|j|j
d�nt|jtj�r||j|j
d�dS)N�Interpolation ErrorrP�	reference�
%(reference)s)rPr�r�r�)rPr�r�r�)
r�r�r/�InterpolationMissingOptionErrorrMr�r:rsr&r1rar�r�)rr-r�rrr	� test_interpolation_missing_valuess
z5ConfigParserTestCase.test_interpolation_missing_valuecCs|jd	d
ddd
g�dS)Nr��	<default>�
getdefault�|<default>|rq�|value|rPr>)r�r�)r�r�)rqr�)rPr>)r>r>)r�)rrrr	�
test_items�s
zConfigParserTestCase.test_itemsc
Cs�|jdj|jdd��}|j|jdd�d�|jtjkrN|j|jdd�d�n0t|jtj	�r~|j
t��|jdd�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.rirrMrQr&r/r1r�r�rU�	TypeError)rr-rrr	�test_safe_interpolation�sz,ConfigParserTestCase.test_safe_interpolationcCs�|jdj|jdd��}|j|jdd�d�|jt|jddd�|jt|jddd�|jt|jddd	�|j|jdd�d�|jdd
d�|j|jdd
�d�dS)
Nz[sect]
option1{eq}foo
r)rfr�r�r8z%foozfoo%zf%oor�zfoo%%barzfoo%bar)r.rirrMrQrUrbr�)rr-rrr	�#test_set_malformatted_interpolation�sz8ConfigParserTestCase.test_set_malformatted_interpolationcCs�|jdj|jdd��}|jt|jddd�|jt|jddd�|jt|jddt��|jt|jddd�|jt|jddd�|jt|jddt��|jt|jdd	d
�|jt|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|j�}|jt|j|j�dS)N)r*rUrbr�r%)rr-rrr	�test_add_section_default�sz-ConfigParserTestCase.test_add_section_defaultN)
rrrr/�ConfigParserr(r�r�r�r�r�r�r�rrrr	r�`sr�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
    cCsT|j|ddd�|j|ddd�|j|ddd�|j|dd	d
�dS)NZnumbers�onerG�twoz%(one)s * 2�threez${common:one} * 3ZhexenZsixteenz${numbers:two} * 8)rM)rr-rrr	�assertMatchesIni�sz4ConfigParserTestCaseNoInterpolation.assertMatchesInicCs|j|j�}|j|�dS)N)r.�inir�)rr-rrr	�test_no_interpolation�sz9ConfigParserTestCaseNoInterpolation.test_no_interpolationcCs|j�}|j|jd��dS)N�)r*�assertIsNoner+)rr-rrr	�test_empty_case�sz3ConfigParserTestCaseNoInterpolation.test_empty_casecCs2Gdd�dtj�}|�}|j|j�|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"eZdZejZej�Zdd�ZdS)�'ConfigParserTestCaseLegacyInterpolationcCs�|jdj|jdd��}|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
r)rfr�r�r8z%foozfoo%zf%oor�zfoo%%bar)r.rirrMrQr�)rr-rrr	r��szKConfigParserTestCaseLegacyInterpolation.test_set_malformatted_interpolationN)	rrrr/r�r(r�r&r�rrrr	r��sr�c@seZdZdZdZdZdS)	�)ConfigParserTestCaseNonStandardDelimiters�:=�$�//�"N)rr)rr)rr)rrrrr r!rrrr	r��sr�c@seZdZdZdS)�-ConfigParserTestCaseNonStandardDefaultSectionZgeneralN)rrrr%rrrr	r�src@s6eZdZejZdjdd�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�}xLtd�D]@}dj|�}|j|�x&td�D]}|j|dj|�|j�q4WqWttjd��}|j	|�WdQRXdS)N�dz	section{}�
z
lovely_spam{}�w)
r*r�rir�r��wonderful_spamr�r�TESTFNr�)rr-r
�s�jr�rrr	�setUps

zMultilineValuesTestCase.setUpcCstjtj�dS)N)�os�unlinkrr)rrrr	�tearDownsz MultilineValuesTestCase.tearDowncCsJ|j�}ttj��}|j|�WdQRX|j|jdd�|jjdd��dS)NZsection8Zlovely_spam4z	
�
)	r*r�rrr�rMrQr
�replace)rZcf_from_filer�rrr	� test_dominating_multiline_valuess
z8MultilineValuesTestCase.test_dominating_multiline_valuesN)rrrr/r�r(rr
rrrrrrr	r�s
rc@s*eZdZejZdd�Zdd�Zdd�ZdS)�RawConfigParserTestCasecCsZ|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�rMrQ)rr-rfrrr	r�sz*RawConfigParserTestCase.test_interpolationcCs|jd
ddd
dg�dS)Nr��	<default>r��
|%(default)s|rq�
|%(name)s|rP�	%(value)sr>)r�r)r�r)rqr)rPr)r>r>)r�)rrrr	r�*s
z"RawConfigParserTestCase.test_itemscCs
|j�}|jd�|jddd�|jddddddddd	d
g�|jdddd
i�|j|jdd�d�|j|jdd�ddddddd	d
g�|j|jdd�dd
i�|jd�|jddd�|j|jdd�d�|jtjk�rdd�|_|jddd�|j|jdd�d�dS)Nz
non-stringr?rrNr��r���
r'Zpign��!	@rpzthis is sickTcSs|S)Nr)r�rrr	�<lambda>AszBRawConfigParserTestCase.test_set_nonstring_types.<locals>.<lambda>)	r*r�r�rMrQZ_dictr/r0�optionxform)rr-rrr	r�1s 


z0RawConfigParserTestCase.test_set_nonstring_typesN)	rrrr/r�r(r�r�r�rrrr	rsrc@seZdZdZdZdZdS)	�,RawConfigParserTestCaseNonStandardDelimiters�:=r�//rN)r!r)r"r)r"r)rrrrr r!rrrr	r Fsr c@s&eZdZejZd	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-filezutf-8)r��globalZhomesZprinterszprint$z
pdf-generatorZtmpZAgustinZ	workgroupZMDKGROUPzmax log size�2zhosts allowz127.zecho commandz
cat %s; rm %s)rr�r*r�rMrLrQrR)rZsmbconfr-r�rLrrr	�test_readingRs
z)RawConfigParserTestSambaConf.test_readingN)rrr$)r%)
rrrr/r�r(r r!r"r(rrrr	r#Ls
r#c@s\eZdZejZej�ZdZdZ	ddd�Z
dd�Zdd	�Zd
d�Z
dd
�Zdd�Zdd�ZdS)�)ConfigParserTestCaseExtendedInterpolation�commonTNcCs"|j|�}|r||_|j|�|S)N)r*rr+)rr,rrr-rrr	r.fs


z4ConfigParserTestCaseExtendedInterpolation.fromstringcCsP|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.rkrlr�rM)rr-rfrrr	�test_extended_interpolationms*zEConfigParserTestCaseExtendedInterpolation.test_extended_interpolationcCs`|jtjd�j��}|jtj��|ddWdQRX|jtj��|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�|jd�}|j|ddd�|j|ddd�|j|ddd�tj}|j|��}|dd	WdQRX|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.rMr/r�rUr`r�ra)rr-Zexception_classrgrrr	�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)rkrlr�r.rM)rr�r-rfrrr	�test_case_sensitivity_basic�s

zEConfigParserTestCaseExtendedInterpolation.test_case_sensitivity_basiccCs�tjd�j�}|jtj��|j|�}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�sz[ConfigParserTestCaseExtendedInterpolation.test_case_sensitivity_conflicts.<locals>.<lambda>)rr*rsr>r�r/r0za better valuezA Better Valuer1r8zvalue redefinedr�zA Better Value Redefined)rkrlr�rUr/rjr.rM)rr�r-rfrrr	�test_case_sensitivity_conflicts�s
zIConfigParserTestCaseExtendedInterpolation.test_case_sensitivity_conflictsc-Cs�|jd�}|jtj��|ddWdQRX|jtj��|ddWdQRX|jtj��|ddWdQRX|jtj��|ddWdQRX|jtj��|ddWdQRX|jt��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_errors�sz;ConfigParserTestCaseExtendedInterpolation.test_other_errors)NN)rrrr/r�r(�ExtendedInterpolationr&r%r$r.r+r-r.r2r3r5rrrr	r)`s
-r)c@seZdZdZdS)�ConfigParserTestCaseNoValueTN)rrrrrrrr	r7sr7c@s2eZdZejZdhZdhZdZdd�Z	dd�Z
dS)	�ConfigParserTestCaseTrickyFilerrTcCs|tjd�}|j�}|jt|j|dd��d�|j|j�ddddd	d
dg�|j|j|jdd
did�d�|j	t
��|j|jddd
did�WdQRX|jt|jdd�jd��d�|jt|jdd�jd��d�d}|j
|j|d��|j|j|d�d�|jt|jd��d�|j	tj��|jd	�WdQRX|j|jd
d�d�|j|jd
d�|jd
d��|j|jdd�d�dS)Nzcfgparser.3zutf-8)r�rZstrangeZ
corruptionz&yeah, sections can be indented as wellzanother one!zno values hereztricky interpolationzmore interpolationZgoZinterpolatez-1)rDT)�rawrD�otherr�r>rzare they subsectionszlets use some Unicodeu	片仮名r�Zletszdo thiszgo shopping���)rr�r*rMrOr�rLrRr%rUrbrQ�splitr]rTrr/r�)rr�r-Zlongnamerrr	�test_cfgparser_dot_3s6
z3ConfigParserTestCaseTrickyFile.test_cfgparser_dot_3cCs:tjd�}|j�}|jt��|j|dd�WdQRXdS)Nzcfgparser.3�ascii)r�)rr�r*rU�UnicodeDecodeErrorr�)rr�r-rrr	�test_unicode_failure5s
z3ConfigParserTestCaseTrickyFile.test_unicode_failureN)rrrr/r�r(rr rr>rArrrr	r8s r8c@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�}|jd�|jddd�tj�}|j|�|j�S)NF)rr:rs)r�r�r�r�r�r�)rr(�cpr�rrr	�prepareEs


zIssue7005TestCase.preparecCs>tjdd�}|jd�|jt��|jddd�WdQRXdS)NF)rr:rs)r/r�r�rUr�r�)rrCrrr	�test_none_as_value_stringifiedNs
z0Issue7005TestCase.test_none_as_value_stringifiedcCs|jtj�}|j||j�dS)N)rDr/r�rM�expected_output)rr�rrr	�"test_none_as_value_stringified_rawTsz4Issue7005TestCase.test_none_as_value_stringified_rawN)rrr�__doc__rFrDrErGrrrr	rB<s
	rBc@seZdZeZdd�ZdS)�SortedTestCasecCs0|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�rMr�)rr-r�rrr	�test_sorted\s



zSortedTestCase.test_sortedN)rrrrr#rJrrrr	rIYsrIc@s"eZdZejZdZdZdd�ZdS)�CompatibleTestCasez#;rcCsTtjd�}|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)rkrlr.rMrQ)rrnr-rrr	�test_comment_handlingus
z(CompatibleTestCase.test_comment_handlingN)	rrrr/r�r(r r!rLrrrr	rKpsrKc@seZdZejZddd�ZdS)�CopyTestCaseNcCsx|j|�}|j|�|j�}|j|�xL|j�D]@}|j|jkrBq0x,||jj�D]\}}|||krR||=qRWq0W|S)N)r*r+rurrPr%r)rr,rr-Zcf_copyr:r�r>rrr	r.�s


zCopyTestCase.fromstring)N)rrrr/r�r(r.rrrr	rM�srMc@seZdZdd�Zdd�ZdS)�FakeFilec	Cs6tjd�}t|��}|j�|_|jj�WdQRXdS)Nzcfgparser.1)rr�r��	readlines�lines�reverse)r�	file_pathr�rrr	�__init__�s


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

zFakeFile.readlineN)rrrrSr�rrrr	rN�srNccs$|j�}x|r|V|j�}q
WdS)z+As advised in Doc/library/configparser.rst.N)r�)r��linerrr	�readline_generator�srVc@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�ReadFileTestCasecCs�tjd�g}y|j|djd��Wntk
r8YnXxb|D]Z}tj�}t|��}|j|�WdQRX|j	d|�|j	d|d�|j
|ddd�q@WdS)Nzcfgparser.1r�utf8zFoo Barr8r�)rr�rJ�encode�UnicodeEncodeErrorr/r�r�r��assertInrM)rZ
file_pathsrRrYr�rrr	�	test_file�s

zReadFileTestCase.test_filecCsZtjd�j�jd�}tj�}|j|�|jd|�|jd|d�|j|ddd�dS)Nz%
        [Foo Bar]
        foo=newbarrzFoo Barr8r�)	rkrlr�r=r/r�r�r[rM)rrPrYrrr	�
test_iterable�s
zReadFileTestCase.test_iterablecCsntj�}|jt��|jt��WdQRX|jtt���|jd|�|jd|d�|j|ddd�dS)z
Issue #11670.NzFoo Barr8r�)	r/r�rUr�r�rNrVr[rM)rrYrrr	�test_readline_generator�sz(ReadFileTestCase.test_readline_generatorc CsTtjd�j�jd�}tj�}|jtj��}|j|dd�WdQRX|j	t
|j�d�tjd�j�jd�}tj�}|jtj��}|j|dd�WdQRX|j	t
|j�d�tjd	�j�jd�}tj�}|jtj
��}|j|dd�WdQRX|j	t
|j�d
�tjd�j�jd�}tj�}|jtj��}|j|dd�WdQRX|j	t
|j�d�dS)
z
Issue #18260.z"
        [badbad]
        [badbad]rsbadbad)r�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')rkrlr�r=r/r�rUrmr�rMr�r`rjr�r�)rrPrYZdserrr	�test_source_as_bytes�s@z%ReadFileTestCase.test_source_as_bytesN)rrrr\r]r^r_rrrr	rW�s

rWc@sPeZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�ZdS)�CoverageOneHundredTestCasez"Covers edge cases in the codebase.cCsftjdd�}|j|jd�|j|jd�|j|jd�|j|jd�|j|jd�|jt|�d�dS)Nr:rsz3Option 'option' in section 'section' already exists)r:rsNN)	r/rjrMr:rsr��linenorar�)rr�rrr	�test_duplicate_option_errorsz6CoverageOneHundredTestCase.test_duplicate_option_errorcCs<tjddd�}|j|jd�|j|jd�|j|jd�dS)Nrsr:�rawval)rsr:rc)r/r�rMrarsr:)rr�rrr	�test_interpolation_depth_errors
z9CoverageOneHundredTestCase.test_interpolation_depth_errorcCs�|jt��}tj�WdQRX|jt|j�d�|jt��}tjddd�WdQRX|jt|j�d�tjdd�}|j|jd�tj	dd��4}tj
d	t�|j|jd�d|_|j|jd�WdQRXx|D]}|j
|jtk�q�WdS)
Nz%Required argument `source' not given.r��filename)r�rez:Cannot specify both `filename' and `source'. Use `source'.)reT)�record�always)rUrbr/r�rMr�r`r��warnings�catch_warnings�simplefilter�DeprecationWarningrer\�category)rrgr�r	�warningrrr	�test_parsing_errors
z-CoverageOneHundredTestCase.test_parsing_errorcCs�tj�}|jd�|jtj��}|ddWdQRX|jt|j�d�|jtj��}|ddWdQRX|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+rUr4rMr�r`)rrYrgrrr	�test_interpolation_validation(sz8CoverageOneHundredTestCase.test_interpolation_validationcCs�tjd�}tj�}tjdd�� }tjdt�|j|dd�WdQRXx|D]}|j	|j
tk�qJW|jt|�d�|j|dd	d
�dS)Nz2
        [section]
        option = value
        T)rfrgr�)rerr:rsr>)
r�r�r/r�rhrirjrkZreadfpr\rlrMrO)rr�rYr	rmrrr	�test_readfp_deprecation9s
z2CoverageOneHundredTestCase.test_readfp_deprecationcCsNtjdd��}tjdt�tj�}WdQRXx|D]}|j|jtk�q2WdS)NT)rfrg)rhrirjrkr/ZSafeConfigParserr\rl)rr	rYrmrrr	�!test_safeconfigparser_deprecationGs

z<CoverageOneHundredTestCase.test_safeconfigparser_deprecationcCs*tj�}|jd�|jt|d�d�dS)Nz7
            [section]
            key = value
        r:z<Section: section>)r/r�r+rM�repr)rrYrrr	�test_sectionproxy_reprNsz1CoverageOneHundredTestCase.test_sectionproxy_reprcCs@tj�}ddl}|j|jd<|jd�|jd|j�|j|jdd�d�|j|jdd�d	�|j|djd�d�|j|djd�d	�|`|j	t
��|jdd�WdQRX|jd|j�|jd=|jd|j�|j	t
��|jdd�WdQRX|j	t
��|djd�WdQRX|j	t
��|djd�WdQRXdS)
Nr�decimalzS
            [s1]
            one = 1
            [s2]
            two = 2
        �s1r�r�s2r�r)r/r�rt�Decimal�
convertersr+r[rM�
getdecimalrUrZr�)rrYrtrrr	�"test_inconsistent_converters_stateVs,z=CoverageOneHundredTestCase.test_inconsistent_converters_stateN)rrrrHrbrdrnrorprqrsrzrrrr	r`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.cCshddl}tjd�}xPt|jd�D]>}|j||�}|j|�}|j|j|j�|jt	|�t	|��q"WdS)Nrr>r)
�pickler/�Errorr��HIGHEST_PROTOCOL�dumps�loadsrM�messagerr)rr|�e1�proto�pickled�e2rrr	�
test_errorvs

z$ExceptionPicklingTestCase.test_errorcCs�ddl}tjd�}xpt|jd�D]^}|j||�}|j|�}|j|j|j�|j|j	|j	�|j|j
|j
�|jt|�t|��q"WdS)Nrr:r)r|r/rVr�r~rr�rMr�rar:rr)rr|r�r�r�r�rrr	�test_nosectionerrors

z-ExceptionPicklingTestCase.test_nosectionerrorcCs�ddl}tjdd�}x�t|jd�D]n}|j||�}|j|�}|j|j|j�|j|j	|j	�|j|j
|j
�|j|j|j�|jt|�t|��q$WdS)Nrrsr:r)
r|r/rWr�r~rr�rMr�rar:rsrr)rr|r�r�r�r�rrr	�test_nooptionerror�s
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
|��q&WdS)Nrr:r�rpr)r|r/rmr�r~rr�rMr�rar:r�rarr)rr|r�r�r�r�rrr	�test_duplicatesectionerror�s
z4ExceptionPicklingTestCase.test_duplicatesectionerrorcCs�ddl}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|��q(WdS)Nrr:rsr�rpr)r|r/rjr�r~rr�rMr�rar:rsr�rarr)rr|r�r�r�r�rrr	�test_duplicateoptionerror�s

z3ExceptionPicklingTestCase.test_duplicateoptionerrorcCs�ddl}tjddd�}x�t|jd�D]n}|j||�}|j|�}|j|j|j�|j|j	|j	�|j|j
|j
�|j|j|j�|jt|�t|��q&WdS)Nrrsr:�msgr)
r|r/ZInterpolationErrorr�r~rr�rMr�rar:rsrr)rr|r�r�r�r�rrr	�test_interpolationerror�s
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
|��q(WdS)Nrrsr:rcr�r)r|r/r�r�r~rr�rMr�rar:rsr�rr)rr|r�r�r�r�rrr	�$test_interpolationmissingoptionerror�s
z>ExceptionPicklingTestCase.test_interpolationmissingoptionerrorcCs�ddl}tjddd�}x�t|jd�D]n}|j||�}|j|�}|j|j|j�|j|j	|j	�|j|j
|j
�|j|j|j�|jt|�t|��q&WdS)Nrrsr:r�r)
r|r/r4r�r~rr�rMr�rar:rsrr)rr|r�r�r�r�rrr	�test_interpolationsyntaxerror�s
z7ExceptionPicklingTestCase.test_interpolationsyntaxerrorcCs�ddl}tjddd�}x�t|jd�D]n}|j||�}|j|�}|j|j|j�|j|j	|j	�|j|j
|j
�|j|j|j�|jt|�t|��q&WdS)Nrrsr:rcr)
r|r/r�r�r~rr�rMr�rar:rsrr)rr|r�r�r�r�rrr	�test_interpolationdeptherror�s
z6ExceptionPicklingTestCase.test_interpolationdeptherrorcCsnddl}tjd�}|jdd�|jdd�|jdd�x�t|jd�D]n}|j||�}|j|�}|j|j	|j	�|j|j
|j
�|j|j|j�|j|j|j�|jt
|�t
|��qFWtjd	d
�}|jdd�|jdd�|jdd�x�t|jd�D]n}|j||�}|j|�}|j|j	|j	�|j|j
|j
�|j|j|j�|j|j|j�|jt
|�t
|��q�WdS)Nrr�rZline1rZline2rZline3re)re)r|r/r�rJr�r~rr�rMr�rar��errorsrr)rr|r�r�r�r�rrr	�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
|��q&WdS)NrrerprUr)r|r/r�r�r~rr�rMr�rarUr�rarr)rr|r�r�r�r�rrr	�test_missingsectionheadererrors
z8ExceptionPicklingTestCase.test_missingsectionheadererrorN)rrrrHr�r�r�r�r�r�r�r�r�r�r�rrrr	r{ss	

r{c@seZdZdZdd�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)Nrr�//)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)rrr�)r/r�r+rM)r�cfgrrrr	�test_strippings z-InlineCommentStrippingTestCase.test_strippingN)rrrrHr�rrrr	r�sr�c@s8eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�ZdS)
�ExceptionContextTestCasezO Test that implementation details doesn't leak
    through raising exceptions. c
CsNtj�}|jd�|jtj�}|�|jdd�WdQRX|j|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�rQrXr`�__suppress_context__)rrYrgrrr	�test_get_basic_interpolation6sz5ExceptionContextTestCase.test_get_basic_interpolationc
CsVtjtj�d�}|jd�|jtj�}|�|jdd�WdQRX|j|jj	d�dS)N)r&z�
        [Paths]
        home_dir: /Users
        my_dir: ${home_dir1}/lumberjack
        my_pictures: ${my_dir}/Pictures
        r�r�T)
r/r�r6r+rUr�rQrXr`r�)rrYrgrrr	�test_get_extended_interpolationCsz8ExceptionContextTestCase.test_get_extended_interpolationc
CsHtj�}|jd�|jtj��}|jd�WdQRX|j|jjd�dS)Nz2
        [Paths]
        home_dir: /Users
        r�T)	r/r�r+rUrVr�rXr`r�)rrYrgrrr	�test_missing_optionsQsz-ExceptionContextTestCase.test_missing_optionscCsBtj�}|jtj��}|jddd�WdQRX|j|jjd�dS)N�Section1�an_intZ15T)r/r�rUrVr�rXr`r�)rrvrgrrr	�test_missing_section[sz-ExceptionContextTestCase.test_missing_sectionc
Cs@tj�}|jtj��}|jdd�WdQRX|j|jjd�dS)Nr�r�T)r/r�rUrVr_rXr`r�)rrvrgrrr	�test_remove_optionasz+ExceptionContextTestCase.test_remove_optionN)	rrrrHr�r�r�r�r�rrrr	r�2s

r�cs0eZdZdZejZd�fdd�	Zdd�Z�Z	S)�ConvertersTestCasez Introduced in 3.5, issue #18159.Ncs t�j|d�}dd�|jd<|S)N)rcSsdd�|j�D�S)NcSsg|]}|j�r|j��qSr)r�)rr�rrr	roszBConvertersTestCase.newconfig.<locals>.<lambda>.<locals>.<listcomp>)r=)�vrrr	rosz.ConvertersTestCase.newconfig.<locals>.<lambda>rN)�superr*rx)rrr))�	__class__rr	r*mszConvertersTestCase.newconfigcACs�|j�}|jd|j�|jd|j�|j|jd�|j|jd�|j|jd�|j|jd�|jt|j�d�|jt��dd�|jd<WdQRX|jt��d	d�|jd<WdQRX|j	d
�|d}|j|dd
�|j|dd�|j|dd�|j|dd�|j|dd�|j|j
dd�d
�|j|j
dd�d�|j|j
dd�d�|j|j
dd�d�|j|j
dd�d�|j|j
dd�d
�|j|jdd�d�|j|jdd�d�|j|j
dd�dddddddg�|j|jdd�d�|j|j
d�d
�|j|jd�d�|j|jd�d�|j|j
d�dddddddg�|j|jd�d�|jt��|jdd�WdQRX|jt��|jd�WdQRXddl}|j|jd<|jd|j�|j|jd�|jt|j�d�|jd�}|j|jdd�|�|j|jd�|�|jd=|jd|j�|jt|j�d�|jt��|jdd�WdQRX|jt��|jd�WdQRX|jt��|jd=WdQRX|jt��|jd=WdQRX|jt��|jd=WdQRXdS) NrBrNr?rAr;cSs|S)Nr)r�rrr	r}sz4ConvertersTestCase.test_converters.<locals>.<lambda>r�cSs|S)Nr)r�rrr	rsz~
        [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��gTrrtr�)r*r[rxr��assertIsNotNonerMrOrUrbr+rQrRrSZgetlistrTrZryrtrwr�r[)rr�rrtZdec0_5rrr	�test_convertersss|
z"ConvertersTestCase.test_converters)N)
rrrrHr/r�r(r*r��
__classcell__rr)r�r	r�hsr�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|j�|j|�|j|jd�dS)NrO)rx)r/r�rOr+rv�	_test_lenr�rx)rr�rrr	�test_converters_at_init�s
z9BlatantOverrideConvertersTestCase.test_converters_at_initcCs�Gdd�dtj�}|�}|j|j�|j|�|j|jd�|j|jdd��|j|jdd��|j	|jdd��|j	|jdd��|j
|jd<|j	|jdd��|j	|jdd��|j	|jdd��|j	|jdd��dS)Ncs@eZdZdZddejd��fdd�
Zddejd�dd�Z�ZS)	zOBlatantOverrideConvertersTestCase.test_inheritance.<locals>.StrangeConfigParserz0a historic borough in south central PennsylvaniaFN)r9rDrCcs"||krdSt�j|||||d�S)NT)r9rDrC)r�rT)rr:rsr9rDrC)r�rr	rT�szZBlatantOverrideConvertersTestCase.test_inheritance.<locals>.StrangeConfigParser.getbooleancSs|j||t|||d�S)N)r9rDrC)Z	_get_convrO)rr:rsr9rDrCrrr	�getlen�szVBlatantOverrideConvertersTestCase.test_inheritance.<locals>.StrangeConfigParser.getlen)	rrrZ
gettysburgr/r1rTr�r�rr)r�r	�StrangeConfigParser�s
r�rOr�r�rB)r/r�r+rvr�r�rxr\rTr]�_convert_to_boolean)rr�r�rrr	�test_inheritance�s
z2BlatantOverrideConvertersTestCase.test_inheritancecCs�|jt|j�d�|jd|j�|jd|j�|jd|j�|j|jd�|j|jd�|j|jd�|j|jdd�d�|j|jdd	�d�|j|jdd
�d�|j|jd	d�d�|j|jd	d	�d�|j|jd	d
�d�|j|jd	dd
d�d
�|jtj	��|jd	d�WdQRX|j|djd�d�|j|djd	�d�|j|djd
�d�|j|d	jd�d�|j|d	jd	�d�|j|d	jd
�d�|j|d	jdd
�d
�|j|d	jd�d�dS)Nr;rBrOZtysburgr?rAr�r�r�r��Zfourr)rC)
rMrOrxr[r�r�r�rUr/rW)rr�rrr	r��s0z+BlatantOverrideConvertersTestCase._test_lencs�tj��dd��_�fdd��_�j|j�|jt�j�d�|j	d�j�|j
d�j�|j�jd�|j�jd�|j�jd�|j�jd	d	��|j�jd
d
��|j�jd	d
��|j�jd
d	���j
�jd<|j�jd	d	��|j�jd
d
��|j�jd	d
��|j�jd
d	��|j�jd	d	�d�|j�jd	d
�d�|j�jd	d�d
�|j�jd
d	�d�|j�jd
d
�d�|j�jd
d�d�|jt��|j�d	jd	�d�WdQRX|jt��|j�d
jd	�d�WdQRXdS)NcSsdS)NTr)r:rsrrr	r	szLBlatantOverrideConvertersTestCase.test_instance_assignment.<locals>.<lambda>cst�||�S)N)rO)r:rs)r�rr	r
srrBrOr?rAr�r�r�r�r�r;)r/r�rTr�r+rvrMrOrxr[r�r�r\r�r]rUrZ)rr)r�r	�test_instance_assignments:
 z:BlatantOverrideConvertersTestCase.test_instance_assignmentN)	rrrrHrvr�r�r�r�rrrr	r��sr�c@seZdZdd�ZdS)�MiscTestCasecCsdh}tj|t|d�dS)Nr})�	blacklist)rZcheck__all__r/)rr�rrr	�test__all__*szMiscTestCase.test__all__N)rrrr�rrrr	r�)sr��__main__),�collectionsr/r�rr�rkZunittestrhr�r�UserDictrrr2ZTestCaser�r�r�r�r�rrrr r#r)r7r8rBrIrKrMrNrVrWr`r{r�r�r�r�r�r�mainrrrr	�<module>s`!Z$+,-
Sr$6Ro


Youez - 2016 - github.com/yon3zu
LinuXploit