
    daf                        d dl Z d dlZd dlZd dlmZ d dlmZ d dlZd dlZd dl	Z	d dl
mZ d dlmZmZmZ d dlmZ d dlmZ d dlmZ  G d	 d
      Z G d dej.                        Z G d dej.                        Z G d dej.                        Z G d de      Z G d dej8                        Z G d de      Z G d de      Z G d dej8                        Z  G d de      Z! G d dej.                        Z" G d d ej.                        Z# G d! d"ej.                        Z$ G d# d$ej.                        Z% G d% d&      Z& ejN                   e(ed'      d(       G d) d*ej.                               Z) G d+ d,ej.                        Z* G d- d.ej.                        Z+ G d/ d0ej.                        Z,e-d1k(  r ej\                          yy)2    N)StringIO)TemporaryFile)support)warnings_helperimport_helpercheck_disallow_instantiation)permutations)dedent)OrderedDictc                       e Zd Zd Zy)BadIterablec                     t         NOSErrorselfs    (/root/Python-3.12.4/Lib/test/test_csv.py__iter__zBadIterable.__iter__   s        N)__name__
__module____qualname__r    r   r   r   r      s    r   r   c                   r   e Zd ZdZd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zej<                   ej>                          e jB                  e"      d                      Z#d Z$d Z%d Z&d  Z'd! Z(d" Z)d# Z*d$ Z+d% Z,d& Z-d' Z.d( Z/d) Z0d* Z1y+),Test_Csvz
    Test the underlying C csv parser in ways that are not appropriate
    from the high level interface. Further tests of this nature are done
    in TestDialectRegistry.
    c                 t   | j                  t        |       | j                  t        |d        | j                  t        ||d       | j                  t        ||d       | j                  t        ||d       | j                  t        j                  ||d       | j                  t        ||d        | j                  t        ||d       | j                  t        ||d       | j                  t        ||d        | j                  t        ||d       | j                  t        ||d 	       | j                  t        ||t        j                  d
       | j                  t        ||t        j                  d        | j                  t        ||t        j
                  d
        ||d        ||d        ||d        ||dd        ||dd        ||dd        ||dd        ||d        ||d        ||d        ||d        ||d        ||d        ||d       y )Nr   bad_attr	delimiterXXfoo   	quotecharlineterminatorquoting )r*   r&    
escapechar	Tr!   skipinitialspace)r.   r1   )r&   r1   ^   )assertRaises	TypeErrorcsvError	QUOTE_ALL
QUOTE_NONE)r   ctorargs      r   _test_arg_validzTest_Csv._test_arg_valid   s   )T*)T40)T31=)T3A>)T3DA#))T36)T3$?)T3!<)T3!<)T3tD)T3qA)T3=)T3"%--2 	 	?)T3"%--4 	 	A)T3"%..B 	 	@SC SS!SC SD48STD9SD48SC$7SC SS!SC SF#SV$SF#S(r   c                     | j                  t        j                  g        | j                  t        t        j                  t                      y r   )r<   r6   readerr4   r   r   r   s    r   test_reader_arg_validzTest_Csv.test_reader_arg_valid@   s.    SZZ,'3::{}=r   c                     | j                  t        j                  t                       G d d      }| j	                  t
        t        j                   |              y )Nc                       e Zd Zed        Zy)1Test_Csv.test_writer_arg_valid.<locals>.BadWriterc                     t         r   r   r   s    r   writez7Test_Csv.test_writer_arg_valid.<locals>.BadWriter.writeG   s    r   N)r   r   r   propertyrD   r   r   r   	BadWriterrB   F   s     r   rF   )r<   r6   writerr   r4   r   )r   rF   s     r   test_writer_arg_validzTest_Csv.test_writer_arg_validD   s<    SZZ4	 	 	'3::y{;r   c                     || }| j                  |j                  j                  d       | j                  |j                  j                  d       | j                  |j                  j
                  d        | j                  |j                  j                  d       | j                  |j                  j                  d       | j                  |j                  j                  t        j                         | j                  |j                  j                  d       | j                  |j                  j                  d       | j                  t        t        |j                  d       | j                  t        t         |j                  dd       | j                  t        t        |j                  d       | j                  t        t         |j                  dd        y )	N,T
"Fr!   :r*   )assertEqualdialectr!   assertIsdoublequoter.   r(   r&   r*   r6   QUOTE_MINIMALr1   strictr4   AttributeErrordelattrsetattr)r   r:   argsobjs       r   _test_default_attrszTest_Csv._test_default_attrsL   sB   Dk..4ckk--t4//633V<..4,,c.?.?@ckk22E:ckk((%0.'3;;L.'3;;SQ.'3;;	J.'3;;#T	+r   c                 D    | j                  t        j                  g        y r   )rY   r6   r>   r   s    r   test_reader_attrszTest_Csv.test_reader_attrs^         R0r   c                 T    | j                  t        j                  t                      y r   )rY   r6   rG   r   r   s    r   test_writer_attrszTest_Csv.test_writer_attrsa         XZ8r   c           
         t        dddddt        j                  dd      } ||i |}| j                  |j                  j
                  d       | j                  |j                  j                  d       | j                  |j                  j                  d       | j                  |j                  j                  d       | j                  |j                  j                  d       | j                  |j                  j                  t        j                         | j                  |j                  j                  d       | j                  |j                  j                  d       y )NrM   F\*T)r!   rQ   r.   r(   r&   r*   r1   rS   )dictr6   r9   rN   rO   r!   rP   rQ   r.   r(   r&   r*   r1   rS   )r   r:   rW   kwargsrX   s        r   _test_kw_attrszTest_Csv._test_kw_attrsd   s   4%)S!nnt!# D#F#..4ckk--u5//633T:..4,,cnn=ckk22D9ckk(($/r   c                 D    | j                  t        j                  g        y r   )rf   r6   r>   r   s    r   test_reader_kw_attrszTest_Csv.test_reader_kw_attrst   s    CJJ+r   c                 T    | j                  t        j                  t                      y r   )rf   r6   rG   r   r   s    r   test_writer_kw_attrszTest_Csv.test_writer_kw_attrsw   s    CJJ
3r   c                     G d d      }||fz   } || }| j                  |j                  j                  d       | j                  |j                  j                  d       | j                  |j                  j
                  d       | j                  |j                  j                  d       | j                  |j                  j                  d       | j                  |j                  j                  t        j                         | j                  |j                  j                  d       | j                  |j                  j                  d       y )	Nc                   @    e Zd ZdZdZdZdZdZej                  Z
dZdZy)-Test_Csv._test_dialect_attrs.<locals>.dialect-Fr2   $#TN)r   r   r   r!   rQ   r.   r(   r&   r6   r8   r*   r1   rS   r   r   r   rO   rm   |   s/    IKJNIMMG!Fr   rO   rn   Fr2   ro   rp   T)rN   rO   r!   rP   rQ   r.   r(   r&   r*   r6   r8   r1   rS   )r   r:   rW   rO   rX   s        r   _test_dialect_attrszTest_Csv._test_dialect_attrsz   s    	 	 wj Dk..4ckk--u5//533S9..4,,cmm<ckk22D9ckk((%0r   c                 D    | j                  t        j                  g        y r   )rq   r6   r>   r   s    r   test_reader_dialect_attrsz"Test_Csv.test_reader_dialect_attrs   r\   r   c                 T    | j                  t        j                  t                      y r   )rq   r6   rG   r   r   s    r   test_writer_dialect_attrsz"Test_Csv.test_writer_dialect_attrs   r_   r   c                 (   t        ddd      5 }t        j                  |fi |}|j                  |       |j	                  d       | j                  |j                         ||j                  j                  z          d d d        y # 1 sw Y   y xY wNw+utf-8r+   encodingnewliner   )	r   r6   rG   writerowseekrN   readrO   r(   )r   fieldsexpectre   fileobjrG   s         r   _write_testzTest_Csv._write_test   s|    4'2> 	E'ZZ262FOOF#LLOW\\^#fnn&C&CCE		E 	E 	Es   A0BBc                 F   t        ddd      5 }t        j                  |fi |}| j                  |      5  |j	                  |       d d d        |j                  d       | j                  |j                         d       d d d        y # 1 sw Y   CxY w# 1 sw Y   y xY wrw   )r   r6   rG   r4   r}   r~   rN   r   )r   excr   re   r   rG   s         r   _write_error_testzTest_Csv._write_error_test   s    4'2> 	1'ZZ262F""3' ('(LLOW\\^R0	1 	1( (	1 	1s"   (BB	9BB	BB c                    | j                  t        j                  d        | j                  t        t	                       G d d      }| j                  t         |               G d d      }| j                  t         |       g       y )Nc                       e Zd Zd Zd Zy).Test_Csv.test_write_arg_valid.<locals>.BadListc                      y)N
   r   r   s    r   __len__z6Test_Csv.test_write_arg_valid.<locals>.BadList.__len__   s    r   c                     |dkD  rt         y )N   r   )r   is     r   __getitem__z:Test_Csv.test_write_arg_valid.<locals>.BadList.__getitem__   s    q5!M r   N)r   r   r   r   r   r   r   r   BadListr      s    "r   r   c                       e Zd Zd Zy).Test_Csv.test_write_arg_valid.<locals>.BadItemc                     t         r   r   r   s    r   __str__z6Test_Csv.test_write_arg_valid.<locals>.BadItem.__str__       r   N)r   r   r   r   r   r   r   BadItemr          r   r   )r   r6   r7   r   r   )r   r   r   s      r   test_write_arg_validzTest_Csv.test_write_arg_valid   sf    syy$/w6	" 	" 	w	2	 	 	w4r   c                 @    ddz  }| j                  ||g|d|       y )NXP  rJ   )r   )r   	bigstrings     r   test_write_bigfieldzTest_Csv.test_write_bigfield   s*    %K	)I.#Y10 	1r   c                 @   | j                  g dd       | j                  t        j                  g dt        j                         | j                  g ddt        j
                         | j                  g ddt        j                         | j                  g ddt        j                         | j                  ddgdt        j                         | j                  g d	d
t        j                         | j                  g d	dt        j                         y )Nar$   zp,q	a,1,"p,q"r)   z"a",1,"p,q"z"a","1","p,q"a
br$   z	"a
b","1")r   r+   Nr$   z	"a","",,1z"a","",,"1")
r   r   r6   r7   r9   rR   QUOTE_NONNUMERICr8   QUOTE_STRINGSQUOTE_NOTNULLr   s    r   test_write_quotingzTest_Csv.test_write_quoting   s    4syy-), 	 	9#&#4#4 	 	6#&#7#7 	 	9#&== 	 	2&\#&== 	 	2+#&#4#4 	 	6-#&#4#4 	 	6r   c                    | j                  g ddd       | j                  t        j                  g dd d       | j                  g dddd       | j                  d	gd
dt        j                         | j                  d	gddt        j                  d       | j                  d	gddt        j
                         | j                  g dddt        j
                         | j                  ddgddt        j
                         | j                  ddgddt        j                         | j                  ddgddt        j                         | j                  ddgddt        j                         | j                  ddgddt        j
                         | j                  ddgddt        j                         | j                  g dddt        j                         y )Nr   r   ra   r-   )r   r$   zp,"q"F)r.   rQ   za,1,"p,\"q\""rL   """")r.   r*   z\")r.   r*   rQ   za,1,p\,qr   z\\,az"\\","a"z\ z\\ ,az\,z\\\,,az,\z",\\",a)zC\67zX"zC\\,6,7,"X""")r   r   r6   r7   rR   r9   r8   r   s    r   test_write_escapezTest_Csv.test_write_escape   s   $( 	 	*syy/*.E 	 	C*;$( 	 	?#$(C4E4E 	 	G#$(C4E4E', 	 	. 	#$(CNN 	 	D$(CNN 	 	D$h$(#.. 	 	B$h$(#2C2C 	 	E$l$(#-- 	 	A%y$(#2C2C 	 	E%{$(#.. 	 	B%{$(#2C2C 	 	E02C$(#2C2C 	 	Er   c                    dD ]  }| j                  |      5  t               5 }t        j                  ||      }|j	                  ddg       |j	                  ddg       |j	                  ddg       | j                  |j                         d	| d
| d|        d d d        d d d         y # 1 sw Y   xY w# 1 sw Y   xY w)N)rK   
rb   z!@# r'   r   br$   r   rb   r   a,bz1,2z"","
")subTestr   r6   rG   r}   rN   getvalue)r   r(   siorG   s       r   test_write_lineterminatorz"Test_Csv.test_write_lineterminator   s    = 
	CN^< 	CZ C3 ZZNKFOOS#J/OOQF+OOT4L1$$S\\^'*>*:'*>*:'00@&BCC	C 	C
	CC C	C 	Cs#   B<A:B0B<0B95B<<C	c                    | j                  t        g d      d       | j                  t        g d      d       | j                  t        g       d       | j                  t        d g      d       | j                  t        j                  t        d g      t        j
                         | j                  t        d d g      d       y )	Nr   r   )r   r$   Nza,1,r+   ""r)   rJ   )r   iterr   r6   r7   r9   r   s    r   test_write_iterablezTest_Csv.test_write_iterable   s    o.<n-v6b2&tft,syy$v,OtTl+S1r   c                     G d d      }t        j                   |             }| j                  t        |j                  dgg       t        ddd      5 }t        j                  |      }| j                  t        |j                  d        |j	                  ddgd	d
gg       |j                  d       | j                  |j                         d       d d d        y # 1 sw Y   y xY w)Nc                       e Zd Zd Zy)+Test_Csv.test_writerows.<locals>.BrokenFilec                     t         r   r   )r   bufs     r   rD   z1Test_Csv.test_writerows.<locals>.BrokenFile.write  r   r   N)r   r   r   rD   r   r   r   
BrokenFiler     r   r   r   r   rx   ry   r+   rz   r   cdr   z
a,b
c,d
)
r6   rG   r4   r   	writerowsr   r5   r~   rN   r   )r   r   rG   r   s       r   test_writerowszTest_Csv.test_writerows  s    	 	 JL)'6#3#3seW=4'2> 	?'ZZ(Fi)9)94@sCj3*56LLOW\\^-=>	? 	? 	?s   A?CC'c                    t        ddd      5 }t        j                  |      }|j                  dd gd dgg       |j	                  d       | j                  |j                         d       d d d        t        ddd      5 }t        j                  |      }|j                  d gdgg       |j	                  d       | j                  |j                         d	       d d d        t        ddd      5 }t        j                  |      }|j                  dgd gg       |j	                  d       | j                  |j                         d
       d d d        y # 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   y xY w)Nrx   ry   r+   rz   r   r   r   za,
,d
z""
a
za
""
)r   r6   rG   r   r~   rN   r   r   r   rG   s      r   test_writerows_with_nonez!Test_Csv.test_writerows_with_none  sH   4'2> 	='ZZ(FsDkD#;78LLOW\\^^<		= 4'2> 	<'ZZ(Ftfse_-LLOW\\^];		< 4'2> 	<'ZZ(FsedV_-LLOW\\^];		< 	<	= 	=	< 	<	< 	<s&   AEAE&5AE2E#&E/2E;c                    | j                  dd       | j                  dgd       | j                  t        j                  dgt        j                         | j                  dgdt        j
                         | j                  dgdt        j                         | j                  d gd       | j                  t        j                  d gt        j                         | j                  t        j                  d gt        j
                         | j                  t        j                  d gt        j                         | j                  ddgd       | j                  d d gd       y )Nr   r+   r   r)   rJ   )r   r   r6   r7   r9   r   r   r   s    r   test_write_empty_fieldsz Test_Csv.test_write_empty_fields#  s   R "t$syy2$G"tS->->?"tS->->?$&syy4&#..Isyy4&#:K:KLsyy4&#:K:KL"b3'$s+r   c                    | j                  dgddd       | j                  dgddd       | j                  d gddd       | j                  d gddd       | j                  ddgddd       | j                  ddgddd       | j                  d d gddd       | j                  d d gddd       | j                  ddgdddt        j                         | j                  t        j                  ddgddt        j                         t        j
                  t        j                  fD ]2  }| j                  ddgddd|       | j                  ddgddd|       4 t        j                  t        j
                  t        j                  fD ]@  }| j                  d d gddd|       | j                  t        j                  d d gdd|       B y )	Nr+   r   r,   Fr0   Tz"" "")r!   r1   r*   )r   r6   r9   r   r7   r   r   )r   r*   s     r   'test_write_empty_fields_space_delimiterz0Test_Csv.test_write_empty_fields_space_delimiter0  s   "tsUK"tsTJ$uM$tL"b3#N"b7cDQ$scER$w#PTU"b3#!$ 	 	1syy2r(),t'*~~ 	 	7 ((#*;*;; 	.Gb"Xw#PU%,  .b"Xw#PT%,  .	. ~~s'8'8#:K:KK 	4GdD\3#PU%,  .""399tTl-04+2 # 4	4r   c                    t        ddd      5 }t        j                  |      }| j                  t        |j
                  d        | j                  t        |j
                  t                      d d d        y # 1 sw Y   y xY w)Nrx   ry   r+   rz   )r   r6   rG   r4   r5   r   r   r   r   s      r   test_writerows_errorszTest_Csv.test_writerows_errorsM  si    4'2> 	H'ZZ(Fi)9)94@gv'7'7G	H 	H 	Hs   A A88B)categoryc                 &   dd l }|j                  d      }t        ddd      5 }t        j                  |      }|j                  |gg       |j                  d       | j                  |j                         d       d d d        y # 1 sw Y   y xY w)Nr   r   rx   ry   r+   rz   za
)		_testcapiunicode_legacy_stringr   r6   rG   r   r~   rN   r   )r   r   r   r   rG   s        r   test_writerows_legacy_stringsz&Test_Csv.test_writerows_legacy_stringsS  s{     	++C04'2> 	6'ZZ(FqcU#LLOW\\^W5		6 	6 	6s   ABBc                 j    t        j                  |fi |}t        |      }| j                  ||       y r   )r6   r>   listrN   )r   inputr   re   r>   results         r   
_read_testzTest_Csv._read_test_  s.    E,V,f(r   c                 6   | j                  g g        | j                  dgg g       | j                  t        j                  | j                   dgd d       | j                  dgdggd       | j                  t        j                  | j                   dgd        y )	Nr+   z"ab"cr$   rS   abcr   )rQ   s   abcr   r4   r6   r7   r   s    r   test_read_oddinputszTest_Csv.test_read_oddinputsd  s    Brd##))T__")TA 	 	7	UG9A>#))T__!(D	*r   c                    | j                  ddgddgddgg       | j                  ddgddgddgg       | j                  d	d
gddgddgg       | j                  ddgddgddgg       d}| j                  t        j                  |      5  t	        t        j
                  dg             d d d        | j                  t        j                  |      5  t	        t        j
                  dg             d d d        | j                  t        j                  |      5  t	        t        j
                  dg             d d d        y # 1 sw Y   xY w# 1 sw Y   ^xY w# 1 sw Y   y xY w)Nr   zc,dr   r   r   r   za,b
zc,d
za,b
zc,d
za,bzc,dzwith newline=''za,bc,dza,b
c,dza,b
c,d)r   assertRaisesRegexr6   r7   nextr>   )r   errmsgs     r   test_read_eolzTest_Csv.test_read_eoln  s?   #cSI(>?'*c#YS	,BCI.#cSI0FG'*c#YS	,BC"##CIIv6 	+ZL)*	+##CIIv6 	+ZL)*	+##CIIv6 	-\N+,	- 	-		+ 	+	+ 	+	- 	-s$    E E EEEE%c                    | j                  dgddgg       | j                  dgdgg       | j                  dgdggd       | j                  t        j                  | j                   dgg d	       | j                  t        j                  | j                   dgg d	       | j                  t        j                  | j                   dgg dd
       y )Nza,"r   r+   z"ar2   r   r-   Tr   )r.   rS   r   r   s    r   test_read_eofzTest_Csv.test_read_eof|  s    3)-#(xC8#))T__ugr$O#))T__tfbN#))T__%D 	 	Br   c                     | j                  dgdgg       | j                  dgg dg       | j                  dgg dg       | j                  dgg dgd       | j                  d	gg dg       y )
Nr   a, b,c)r   z br   za,b ,c)r   zb r   za,b\ ,cra   r-   za," b",cr   r   s    r   test_read_nulzTest_Csv.test_read_nul  sj    $)&7%89&7%89(9':tL(9':;r   c                     | j                  dgg dg       | j                  dgg dgd       | j                  dgg dgd       y )Nza,b,cr   r   r   za;b;c;r    za b cr   r   r   s    r   test_read_delimiterzTest_Csv.test_read_delimiter  sC    	O#45	O#4Do%6$Gr   c                    | j                  dgg dgd       | j                  dgddggd       | j                  dgddggd       | j                  d	gddggd       | j                  d
gddggd       | j                  dgddggd       | j                  dgg dgd       | j                  dgg dgd       | j                  dgg dgd        | j                  dgg dg       y )Nza,\b,cr   ra   r-   za,b\,cr   zb,cza,"b\,c"za,"b,\c"z	a,"b,c\""zb,c"za,"b,c"\zb,c\za,^b,cr2   r   r   )r   z\br   r   r   s    r   test_read_escapezTest_Csv.test_read_escape  s    o%64HsEl^Ee~$Ge~$G#vDIg'7DI
_$5#Fo%64H&7%8TJ&7%89r   c                    | j                  dgg dg       | j                  dgg dgd d       | j                  dgg dgt        j                  d       | j                  dgg dgt        j                  	       | j                  d
gddgg       | j	                  t
        | j                   dgg gt        j                  	       | j                  dgg dgd       | j                  dgg dgd       y )Nz	1,",3,",5)1z,3,5)r   rL   3rL   r   ra   )r&   r.   r*   r.   z,3,"5",7.3, 9)r+      r   g333333@	   r)   z"a
b", 7r   z 7zabc,3z	1,@,3,@,5@r%   z	1, ,3, ,5r   )r   r6   r9   r   r4   
ValueErrorr   s    r   test_read_quotingzTest_Csv.test_read_quoting  s    (9':;(A'B"&4 	 	9(A'B #4 	 	A 	),@+A # 4 4 	 	6'78*doo")bT"%"6"6 	 	8 	(9':cJ*;)<Mr   c                 4    | j                  dgg dgd       y )Nzno space, space,  spaces,	tab)zno spacespacespacesz	tabT)r1   r   r   s    r   test_read_skipinitialspacez#Test_Csv.test_read_skipinitialspace  s"    9:AB)- 	 	/r   c                     | j                  g dg dg dg dg gdd       | j                  g ddd	gdd
gd
gg gdd       y )N)za   bz  a  z  r+   )r   r+   r+   r   )r+   r+   r   r+   r+   )r+   r+   r+   r,   Fr0   r   r   r+   Tr   r   s    r   test_read_space_delimiterz"Test_Csv.test_read_space_delimiter  sZ    4+-BLRTU"% 	 	? 	4sc2Yb9"% 	 	>r   c                    t        j                         }	 d}d|z  }|d|}| j                  |g||gg       t        j                  |       | j                  |g||gg       | j                  t        j                         |       t        j                  |dz
         | j	                  t         j
                  | j                  |gg        | j	                  t        t         j                  d        | j	                  t        t         j                  dd        t        j                  |       y # t        j                  |       w xY w)Nr   r   rJ   r$   )r6   field_size_limitr   rN   r4   r7   r5   )r   limitsizer   biglines        r   test_read_bigfieldzTest_Csv.test_read_bigfield  s    $$&	(Dd
I!*I6GOOWII(>'?@  &OOWII(>'?@S113T:  a(cii7)RHi)=)=tDi)=)=q$G  'C  's   DD/ /Ec                    t        j                  g d      }| j                  |j                  d       t	        |       | j                  |j                  d       t	        |       | j                  |j                  d       t	        |       | j                  |j                  d       | j                  t        t        |       | j                  |j                  d       y )N)zline,1zline,2zline,3r   r$   r   r   )r6   r>   rN   line_numr   r4   StopIteration)r   rs     r   test_read_linenumzTest_Csv.test_read_linenum  s    JJ56Q'QQ'QQ'QQ'-q1Q'r   c           	         g dg dg dg dg dg dg}dD ]  }| j                  |      5  t        d	d
d      5 }t        j                  ||      }|j	                  |       |j                  d       t        t        j                  |            D ]  \  }}| j                  |||           	 d d d        d d d         y # 1 sw Y   xY w# 1 sw Y   xY w)Nz
azb
czd
zezfgzhz
izj
kzl
z
mzn
ozp
zqzrsztz

uzv

wzx

rK   r   rb   r'   rx   ry   r+   rz   r   )	r   r   r6   rG   r   r~   	enumerater>   rN   r   rowsr(   r   rG   r   rows          r   test_roundtrip_quoteed_newlinesz(Test_Csv.test_roundtrip_quoteed_newlines  s    ""((((
 1 	7N^< 7"4'2F 7' ZZOF$$T*LLO"+CJJw,?"@ 73((d1g67	77 7	77 77 7s#   CA5C1CC	CC	c           
         g dg dg dg dg dg dg}dD ]  }| j                  |      5  t        d	d
d      5 }t        j                  ||t        j                  d      }|j                  |       |j                  d       t        t        j                  |t        j                  d            D ]  \  }}| j                  |||           	 d d d        d d d         y # 1 sw Y   xY w# 1 sw Y   xY w)Nr	  r
  r  r  r  r  r  r'   rx   ry   r+   rz   ra   )r(   r*   r.   r   r   )
r   r   r6   rG   r9   r   r~   r  r>   rN   r  s          r   (test_roundtrip_escaped_unquoted_newlinesz1Test_Csv.test_roundtrip_escaped_unquoted_newlines  s    ""((((
 1 
	7N^< 	7"4'2F 7' ZZ034QF$$T*LLO"+CJJw?B~~BF-H #I 73 ((d1g677	7 	7
	77 7	7 	7s#   C1BC%C1%C.*C11C:	N)2r   r   r   __doc__r<   r?   rH   rY   r[   r^   rf   rh   rj   rq   rs   ru   r   r   r   r   r   r   r   r   r   r   r   r   r   r   cpython_onlyrequires_legacy_unicode_capir   ignore_warningsDeprecationWarningr   r   r   r   r   r   r   r   r   r   r   r  r  r  r  r   r   r   r   r      s   
 )D><+$190 ,41,19E1516"E>C2?<(,4:H )W))+$_$$.@A6 B , 6)
*-B<H

:N /
>(&
(7$7r   r   c                   N    e Zd Zd Zd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd Zy)TestDialectRegistryc                     | j                  t        t        j                  d        | j                  t        t        j                         | j                  t        j
                  t        j                  d        | j                  t        j
                  t        j                  d       | j                  t        t        j                         | j                  t        j
                  t        j                  d        | j                  t        j
                  t        j                  d       | j                  t        t        j                  d        | j                  t        t        j                  d d        | j                  t        t        j                  ddd       | j                  t        t        j                  dd        | j                  t        t        j                  dd        | j                  t        t        j                  g        y )Nnonesuchr   )badargumentr)   )r4   r5   r6   list_dialectsget_dialectr7   unregister_dialectregister_dialectr   s    r   test_registry_badargsz)TestDialectRegistry.test_registry_badargs  sZ   )S%6%6=)S__5#))S__d;#))S__jA)S%;%;<#))S%;%;TB#))S%;%;ZH)S%9%94@)S%9%94F)S%9%9:q!L)S%9%9:&* 	 	,)S%9%9:"& 	 	()S%9%92>r   c                     G d dt         j                        }d}t        j                         |gz   }|j                          t        j                  ||       | j                  t         j                  |       | j                  t        j                  |      j                  d       t        t        j                               }| j                  ||       y )Nc                       e Zd ZdZy)5TestDialectRegistry.test_registry.<locals>.myexceltsvr/   Nr   r   r   r!   r   r   r   
myexceltsvr(        Ir   r*  r/   )r6   excelr!  sortr$  
addCleanupr#  rN   r"  r!   sorted)r   r*  nameexpected_dialectsgot_dialectss        r   test_registryz!TestDialectRegistry.test_registry  s    	 	--/4&8 T:...5.88$?c//12*L9r   c           	      :   d}t        j                  |d       | j                  t         j                  |       | j	                  t        j
                  |      j                  d       | j	                  g dgt        t        j                  dg|                   y )Nfedcbar   r    )r   YZzX;Y;Z)	r6   r$  r.  r#  rN   r"  r!   r   r>   )r   r0  s     r   test_register_kwargsz(TestDialectRegistry.test_register_kwargs  so    TS1..5.88#>/*DWIt1L,MNr   c           
      f    G d dt         j                        }d}t        j                  ||dddddt         j                  	       | j	                  t         j
                  |       t        j                  |      }| j                  |j                  d       | j                  |j                  d       | j                  |j                  d       | j                  |j                  d       | j                  |j                  d       | j                  |j                  t         j                         y )
Nc                   8    e Zd ZdZdZdZdZdZej                  Z
y)DTestDialectRegistry.test_register_kwargs_override.<locals>.mydialectr/   rL   TFrK   N)r   r   r   r!   r&   rQ   r1   r(   r6   rR   r*   r   r   r   	mydialectr;  '  s'    IIK$#N''Gr   r<  test_dialectr   'FTr   )r!   r&   rQ   r1   r(   r*   )r6   Dialectr$  r8   r.  r#  r"  rN   r!   r&   rQ   r1   r(   r*   )r   r<  r0  rO   s       r   test_register_kwargs_overridez1TestDialectRegistry.test_register_kwargs_override&  s    	( 	( T9'*'*)..2,0%(]]	4 	..5 //$'**C0**C0,,e41148//6#--8r   c                 v     G d dt         j                        }| j                  t         j                  |       y )Nc                       e Zd ZdZy)?TestDialectRegistry.test_incomplete_dialect.<locals>.myexceltsvr/   Nr)  r   r   r   r*  rC  C  r+  r   r*  )r6   r?  r4   r7   )r   r*  s     r   test_incomplete_dialectz+TestDialectRegistry.test_incomplete_dialectB  s&    	 	#))Z0r   c                 j    G d dt         j                        }t        dd      5 }|j                  d       |j	                  d       t        j
                  | |             }| j                  t        |      g d	       | j                  t        |      d
dg       d d d        y # 1 sw Y   y xY w)Nc                   ,    e Zd ZdZej
                  ZdZy)5TestDialectRegistry.test_space_dialect.<locals>.spacer,   ra   N)r   r   r   r!   r6   r9   r*   r.   r   r   r   r   rG  H  s    InnGJr   r   rx   ry   r{   zabc   def
c1ccccc1 benzene
r   rO   )r   r+   r+   defc1ccccc1benzene)r6   r,  r   rD   r~   r>   rN   r   )r   r   r   r>   s       r   test_space_dialectz&TestDialectRegistry.test_space_dialectG  s    	CII 	
 4'2 	DgMM9:LLOZZ9FT&\+ABT&\J	+BC	D 	D 	Ds   A9B))B2c                    t        ddd      5 }t        j                  |g|i |}|j                  g d       |j	                  d       | j                  |j                         |       d d d        y # 1 sw Y   y xY w)Nrx   r+   ry   r|   r{   r$   r   r   r   )r   r6   rG   r}   r~   rN   r   )r   expected	writeargskwwriteargsr   rG   s         r   compare_dialect_123z'TestDialectRegistry.compare_dialect_123T  sj    4g> 	7'ZZC)C{CFOOG$LLOW\\^X6	7 	7 	7s   AA66A?c                     G d dt         j                        } G d dt         j                        } G d dt         j                        } G d dt         j                        } G d	 d
      }t        j                  d|       	 | j                  d       | j                  dd        | j                  d|       | j                  d|       | j                  d |              | j                  dd       | j                  d|d       | j                  d|       t        j                  d       y # t        j                  d       w xY w)Nc                       e Zd ZdZy)5TestDialectRegistry.test_dialect_apply.<locals>.testAr/   Nr)  r   r   r   testArW  ^  r+  r   rX  c                       e Zd ZdZy)5TestDialectRegistry.test_dialect_apply.<locals>.testBrM   Nr)  r   r   r   testBrZ  `      Ir   r[  c                       e Zd ZdZy)5TestDialectRegistry.test_dialect_apply.<locals>.testC|Nr)  r   r   r   testCr^  b  r\  r   r`  c                       e Zd ZdZy)7TestDialectRegistry.test_dialect_apply.<locals>.testUniu   ΛNr)  r   r   r   testUnirb  d  s     Ir   rc  c                       e Zd Zy);TestDialectRegistry.test_dialect_apply.<locals>.unspecifiedNr   r   r   r   r   r   unspecifiedre  g  s    r   rg  z1,2,3
rI  z1	2	3
z1:2:3
z1|2|3
z1;2;3
r   )rO   r!   u	   1Λ2Λ3
)r6   r,  r$  rT  r#  )r   rX  r[  r`  rc  rg  s         r   test_dialect_applyz&TestDialectRegistry.test_dialect_apply]  s!   	CII 		CII 		CII 		!cii 	!	 	 	We,	,$$[1$$[$$?$$[+$F$$]E:$$[%'$B$$['$B$$[%/2 % 4$$%:-4 % 6 ""7+C""7+s   BD7 7Ec                 <   | j                  t        t        j                  g d       | j                  t        t        j                  g d        | j                  t        t        j                  g d       | j                  t        t        j                  g d       y )Nr   r   r    r)   d   )r4   r5   r6   r>   r   s    r   test_bad_dialectz$TestDialectRegistry.test_bad_dialect{  sn    )SZZB)SZZF)SZZrB)SZZsCr   c                     t        j                         D ]<  }t        j                  |      }| j                  t        t
        j
                  |       > y r   )r6   r!  r"  r4   r5   copy)r   r0  rO   s      r   	test_copyzTestDialectRegistry.test_copy  s>    %%' 	=Dood+GiG<	=r   c                     t        j                         D ]^  }t        j                  |      }t        t        j
                  dz         D ](  }| j                  t        t        j                  ||       * ` y )Nr$   )	r6   r!  r"  rangepickleHIGHEST_PROTOCOLr4   r5   dumps)r   r0  rO   protos       r   test_picklezTestDialectRegistry.test_pickle  sc    %%' 	KDood+Gv66:; K!!)V\\7EJK	Kr   N)r   r   r   r%  r3  r8  r@  rD  rM  rT  rh  rl  ro  rv  r   r   r   r  r    s=    ?"
:O981
D7,<D=
Kr   r  c                       e Zd Zd Zd Zy)TestCsvBasec                 
   t        ddd      5 }|j                  |       |j                  d       t        j                  || j
                        }t        |      }| j                  ||       d d d        y # 1 sw Y   y xY w)Nrx   ry   r+   rz   r   rI  )r   rD   r~   r6   r>   rO   r   rN   )r   r   expected_resultr   r>   r   s         r   readerAssertEqualzTestCsvBase.readerAssertEqual  si    4'2> 	6'MM% LLOZZ4<<@F&\FV_5	6 	6 	6s   A!A99Bc                    t        ddd      5 }t        j                  || j                        }|j	                  |       |j                  d       | j                  |j                         |       d d d        y # 1 sw Y   y xY w)Nrx   ry   r+   rz   rI  r   )r   r6   rG   rO   r   r~   rN   r   )r   r   rz  r   rG   s        r   writerAssertEqualzTestCsvBase.writerAssertEqual  sh    4'2> 	>'ZZ4<<@FU#LLOW\\^_=		> 	> 	>s   A$A<<BN)r   r   r   r{  r}  r   r   r   rx  rx    s    6>r   rx  c                       e Zd ZdZd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zy)TestDialectExcelr,  c                 ,    | j                  ddgg       y )Nr   r{  r   s    r   test_singlezTestDialectExcel.test_single      uwi0r   c                 .    | j                  dg dg       y )Nz	1,2,3,4,5)r   2r   4r   r  r   s    r   test_simplezTestDialectExcel.test_simple  s    {-B,CDr   c                 (    | j                  dg        y Nr+   r  r   s    r   test_blanklinezTestDialectExcel.test_blankline      r2&r   c                 .    | j                  dddgg       y )NrJ   r+   r  r   s    r   test_empty_fieldsz"TestDialectExcel.test_empty_fields  s    sb"XJ/r   c                 ,    | j                  ddgg       y )Nr   r+   r  r   s    r   test_singlequotedz"TestDialectExcel.test_singlequoted  s    trdV,r   c                 .    | j                  dddgg       y )Nz"",r+   r  r   s    r   test_singlequoted_left_emptyz-TestDialectExcel.test_singlequoted_left_empty      u2wi0r   c                 .    | j                  dddgg       y )Nz,""r+   r  r   s    r   test_singlequoted_right_emptyz.TestDialectExcel.test_singlequoted_right_empty  r  r   c                 ,    | j                  ddgg       y )Nr   rL   r  r   s    r   test_single_quoted_quotez)TestDialectExcel.test_single_quoted_quote  s    vw/r   c                 ,    | j                  ddgg       y )Nz""""""r   r  r   s    r   test_quoted_quotesz#TestDialectExcel.test_quoted_quotes  s    x4&2r   c                 ,    | j                  ddgg       y )Nza""br  r   s    r   test_inline_quotez"TestDialectExcel.test_inline_quote      vz2r   c                 ,    | j                  ddgg       y )Nza"b"cr  r   s    r   test_inline_quotesz#TestDialectExcel.test_inline_quotes  s    w'4r   c                 ,    | j                  ddgg       y )Nz"a"babr  r   s    r   test_quotes_and_morez%TestDialectExcel.test_quotes_and_more  s     	vx0r   c                 ,    | j                  ddgg       y )Nza"br  r   s    r   test_lone_quotez TestDialectExcel.test_lone_quote  r  r   c                 ,    | j                  ddgg       y )Nz"a" "b"za "b"r  r   s    r   test_quote_and_quotez%TestDialectExcel.test_quote_and_quote  s     	yG9+6r   c                 ,    | j                  ddgg       y )Nz "a"r  r   s    r   test_space_and_quotez%TestDialectExcel.test_space_and_quote  r  r   c                 .    | j                  dg dg       y )Nz#1,2,3,"I think, therefore I am",5,6)r   r  r   zI think, therefore I amr   r   r  r   s    r   test_quotedzTestDialectExcel.test_quoted  s    D!+  ,	-r   c                 .    | j                  dg dg       y )NzJ1,2,3,"""I see,"" said the blind man","as he picked up his hammer and saw")r   r  r   z"I see," said the blind manz"as he picked up his hammer and sawr  r   s    r   test_quoted_quotez"TestDialectExcel.test_quoted_quote  s     k!G  H	Ir   c                 8    d}| j                  |g dg dg       y )NzR1,2,3,"""I see,""
said the blind man","as he picked up his
hammer and saw"
9,8,7,6)r   r  r   z"I see,"
said the blind manz"as he picked up his
hammer and saw)98r   r   r  )r   r   s     r   test_quoted_nlzTestDialectExcel.test_quoted_nl  s+    
 	u!J !2 3	4r   c                 .    | j                  dg dg       y )Nz	12,12,1",)12r  z1"r+   r  r   s    r   test_dubious_quotez#TestDialectExcel.test_dubious_quote  s    {-C,DEr   c                 (    | j                  g d       y r  r}  r   s    r   	test_nullzTestDialectExcel.test_null  r  r   c                 ,    | j                  dggd       y )Nr   zabc
r  r   s    r   test_single_writerz#TestDialectExcel.test_single_writer  s    y)4r   c                 .    | j                  g dgd       y )N)r$   r   r   r      z1,2,abc,3,4
r  r   s    r   test_simple_writerz#TestDialectExcel.test_simple_writer  s     346GHr   c                 .    | j                  g dgd       y )N)r$   r   za"bc"r   r  z1,2,"a""bc""",3,4
r  r   s    r   test_quoteszTestDialectExcel.test_quotes       568OPr   c                 ,    | j                  dggd       y Nabc,defz"abc,def"
r  r   s    r   test_quote_fieldsepz$TestDialectExcel.test_quote_fieldsep      }o>r   c                 .    | j                  g dgd       y )N)r$   r   za
bcr   r  z1,2,"a
bc",3,4
r  r   s    r   test_newlineszTestDialectExcel.test_newlines  s     568MNr   N)r   r   r   rO   r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r   r   r   r  r    s    G1E'0-1103351
17
3-I
4F'5IQ?Or   r  c                   (    e Zd Zej                  ZdZy)EscapedExcelra   N)r   r   r   r6   r9   r*   r.   r   r   r   r  r    s    nnGJr   r  c                   &    e Zd Z e       Zd Zd Zy)TestEscapedExcelc                 ,    | j                  dggd       y )Nr  
abc\,def
r  r   s    r   test_escape_fieldsepz%TestEscapedExcel.test_escape_fieldsep  r  r   c                 ,    | j                  ddgg       y )Nr  r  r  r   s    r   test_read_escape_fieldsepz*TestEscapedExcel.test_read_escape_fieldsep	  s    )>r   N)r   r   r   r  rO   r  r  r   r   r   r  r    s    nG??r   r  c                       e Zd ZdZd Zd Zy)TestDialectUnixunixc                 .    | j                  g dgd       y )N)r$   abc defr   "1","abc def","abc"
r  r   s    r   r  z"TestDialectUnix.test_simple_writer  r  r   c                 .    | j                  dg dg       y )Nr  )r   r  r   r  r   s    r   test_simple_readerz"TestDialectUnix.test_simple_reader  s    69P8QRr   N)r   r   r   rO   r  r  r   r   r   r  r    s    GQSr   r  c                   (    e Zd Zej                  ZdZy)QuotedEscapedExcelra   N)r   r   r   r6   r   r*   r.   r   r   r   r  r    s    ""GJr   r  c                   &    e Zd Z e       Zd Zd Zy)TestQuotedEscapedExcelc                 ,    | j                  dggd       y r  r  r   s    r   test_write_escape_fieldsepz1TestQuotedEscapedExcel.test_write_escape_fieldsep  r  r   c                 ,    | j                  ddgg       y )Nz"abc\,def"
r  r  r   s    r   r  z0TestQuotedEscapedExcel.test_read_escape_fieldsep  s    0I;-@r   N)r   r   r   r  rO   r  r  r   r   r   r  r    s     "G?Ar   r  c                       e Zd Zd Zd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zy)TestDictFieldsc                     t        ddd      5 }t        j                  |g d      }|j                         }| j	                  |d       d d d        y # 1 sw Y   y xY w)Nrx   ry   r+   rz   f1f2f3
fieldnamesr   )r   r6   
DictWriterwriteheaderrN   )r   r   rG   writeheader_return_values       r   test_writeheader_return_valuez,TestDictFields.test_writeheader_return_value%  sV    4'2> 	;'^^G:LMF'-'9'9';$5r:	; 	; 	;s   <AAc                    t        ddd      5 }t        j                  |g d      }|j                          |j	                  d       | j                  |j                         d       |j                  d	d
d       |j	                  d       |j                          | j                  |j                         d       d d d        y # 1 sw Y   y xY w)Nrx   ry   r+   rz   r  r  r   
f1,f2,f3
r   r   )r  r  z	10,,abc
)	r   r6   r  r  r~   rN   readliner}   r   r   s      r   test_write_simple_dictz%TestDictFields.test_write_simple_dict+  s    4'2> 	<'^^G:LMF LLOW--/@OO2U34LLOW\\^];	< 	< 	<s   B0CCc                     t               }t        j                  |g d      }|j                          | j	                  |j                         d       |j                  ddddddd	dg       | j	                  |j                         d
       y )Nr  r  r  r$   r   fr      xyzzf1,f2,f3
1,abc,f
2,5,xyz
)r   r6   r  r  rN   r   r   r   s      r   test_write_multiple_dict_rowsz,TestDictFields.test_write_multiple_dict_rows6  s    *4FG))+^<%s;!"!59; 	<))+=	?r   c                 b    t               }| j                  t        t        j                  |       y r   )r   r4   r5   r6   r  r   r   s     r   test_write_no_fieldsz#TestDictFields.test_write_no_fields@  s    *)S^^W=r   c                    t        ddd      5 }t        j                  |g d      }| j                  t              5 }|j                  ddd	d
       d d d        t        j                        }| j                  d|       | j                  d|       | j                  d|       | j                  d|       d d d        y # 1 sw Y   oxY w# 1 sw Y   y xY w)Nrx   ry   r+   rz   r  r  r   spamr   )f4r  r$   r  z'f4'z'f2'r   )
r   r6   r  r4   r   r}   str	exceptionassertInassertNotIn)r   r   rG   cxr  s        r   #test_write_fields_not_in_fieldnamesz2TestDictFields.test_write_fields_not_in_fieldnamesD  s    4'2> 		*'^^G:LMF"":. D"rE BCDBLL)IMM,	2MM&),VY/MM#y)		* 		*D D		* 		*s#   /CCA%CC	CCc                 l    t               }| j                  t        t        j                  |ddgd       y )Nr  r  raisedextrasaction)r   r4   r   r6   r  r  s     r   &test_typo_in_extrasaction_raises_errorz5TestDictFields.test_typo_in_extrasaction_raises_errorP  s/    **cnngd|'/ 	 	1r   c                 N   t               }t        j                  |ddgd      }ddddd	}| j                  t        t        j                  j
                  ||       t        j                  |ddgd
      }| j                  t        t        j                  j
                  ||       y )Nr  r  raiser   r   r$   r   r   f0r  r  r  RAISE)r   r6   r  r4   r   r}   r   r   rG   dictrows       r   )test_write_field_not_in_field_names_raisez8TestDictFields.test_write_field_not_in_field_names_raiseU  s    *$GL!1A6*cnn&=&=vwO $GL*cnn&=&=vwOr   c                 N   t               }t        j                  |ddgd      }ddddd	}t        j                  j                  ||       | j	                  |j                         d
       t        j                  |ddgd      }t        j                  j                  ||       y )Nr  r  ignorer   r   r$   r   r   r  z1,2
IGNORE)r   r6   r  r}   rN   r   r  s       r   *test_write_field_not_in_field_names_ignorez9TestDictFields.test_write_field_not_in_field_names_ignore_  s    *$HM!1A60))+Y7 $HM0r   c                     g d}t               }t        j                  |t        |            }| j	                  |j
                  |       y Nr   )r   r6   
DictReaderr   rN   r  r   r  r  r>   s       r   (test_dict_reader_fieldnames_accepts_iterz7TestDictFields.test_dict_reader_fieldnames_accepts_iterj  9    $
J4
#34**J7r   c                     g d}t               }t        j                  ||      }| j                  |j                  |       y r  )r   r6   r  rN   r  r  s       r   (test_dict_reader_fieldnames_accepts_listz7TestDictFields.test_dict_reader_fieldnames_accepts_listp  4    $
J:.**J7r   c                     g d}t               }t        j                  |t        |            }| j	                  |j
                  |       y r  )r   r6   r  r   rN   r  r   r  r  rG   s       r   (test_dict_writer_fieldnames_rejects_iterz7TestDictFields.test_dict_writer_fieldnames_rejects_iterv  r  r   c                     g d}t               }t        j                  ||      }| j                  |j                  |       y r  )r   r6   r  rN   r  r  s       r   (test_dict_writer_fieldnames_accepts_listz7TestDictFields.test_dict_writer_fieldnames_accepts_list|  r  r   c                 F    t               }t        j                  |d       }y )Nr  )r   r6   r  )r   r  r>   s      r   'test_dict_reader_fieldnames_is_optionalz6TestDictFields.test_dict_reader_fieldnames_is_optional  s    Jd3r   c                     t        dd      5 }|j                  d       |j                  d       t        j                  |g d      }| j                  t        |      dd	d
d       d d d        y # 1 sw Y   y xY w)Nrx   ry   rH  z	1,2,abc
r   r  r  r   r  r   r   rD   r~   r6   r  rN   r   r   r   r>   s      r   test_read_dict_fieldsz$TestDictFields.test_read_dict_fields  sm    4'2 	PgMM-(LLO^^G/ACFT&\#S+NO	P 	P 	Ps   AA22A;c                 0   t        dd      5 }|j                  d       |j                  d       t        j                  |      }| j                  t        |      dddd	       | j                  |j                  g d	       d d d        y # 1 sw Y   y xY w)
Nrx   ry   rH  f1,f2,f3
1,2,abc
r   r   r  r   r  )r   rD   r~   r6   r  rN   r   r  r!  s      r   test_read_dict_no_fieldnamesz+TestDictFields.test_read_dict_no_fieldnames  s    4'2 	DgMM34LLO^^G,FT&\#S+NOV..0BC	D 	D 	Ds   A5BBc           	      l   t        dd      5 }|j                  d       |j                  d       t        j                  |t        t        j                  |                  }| j                  |j                  g d       | j                  t        |      dd	d
d       d d d        y # 1 sw Y   y xY w)Nrx   ry   rH  r$  r   r  r  r   r  r   )	r   rD   r~   r6   r  r   r>   rN   r  r!  s      r   #test_read_dict_fieldnames_from_filez2TestDictFields.test_read_dict_fieldnames_from_file  s    4'2 	PgMM34LLO^^G/3CJJw4G/HJFV..0BCT&\#S+NO	P 	P 	Ps   BB**B3c           	      n   dd l }t        dd      5 }|j                  d       |j                  d       t	        j
                  |      }t        |      }|j                  |g|      D ]6  }| j                  |j                  g d       | j                  |ddd	d       8 	 d d d        y # 1 sw Y   y xY w)
Nr   rx   ry   rH  r$  r  r   r  r   )
	itertoolsr   rD   r~   r6   r  r   chainrN   r  )r   r)  r   r>   firstr  s         r   test_read_dict_fieldnames_chainz.TestDictFields.test_read_dict_fieldnames_chain  s    4'2 	KgMM34LLO^^G,FLE w7 K  !2!24FG  S5&IJK	K 	K 	Ks   BB++B4c                     t        dd      5 }|j                  d       |j                  d       t        j                  |ddg      }| j                  t        |      d	d
g dd       d d d        y # 1 sw Y   y xY w)Nrx   ry   rH  1,2,abc,4,5,6
r   r  r  r  r   r  r   r  r   r   )r  r  Nr   r!  s      r   test_read_longzTestDictFields.test_read_long  sx    4'2 	LgMM-.LLO^^G04d|=FT&\#S3I,K L	L 	L 	Ls   AA44A=c                    t        dd      5 }|j                  d       |j                  d       t        j                  |ddgd	      }| j                  t        |      d
dg dd       d d d        y # 1 sw Y   y xY w)Nrx   ry   rH  r.  r   r  r  _rest)r  restkeyr   r  r/  r  r  r2  r   r!  s      r   test_read_long_with_restz'TestDictFields.test_read_long_with_rest  s{    4'2 	OgMM-.LLO^^G04d|WNFT&\#S6L,N O	O 	O 	Os   AA55A>c                 8   t        dd      5 }|j                  d       |j                  d       t        j                  |d      }| j                  |j                  dd	g       | j                  t        |      d
dg dd       d d d        y # 1 sw Y   y xY w)Nrx   ry   rH  zf1,f2
1,2,abc,4,5,6
r   r2  r3  r  r  r   r  r/  r4  )r   rD   r~   r6   r  rN   r  r   r!  s      r   &test_read_long_with_rest_no_fieldnamesz5TestDictFields.test_read_long_with_rest_no_fieldnames  s    4'2 	OgMM67LLO^^GW=FV..t=T&\#S6L,N O	O 	O 	Os   A9BBc                 `   t        dd      5 }|j                  d       |j                  d       t        j                  |dj                         d      }| j                  t        |      d	d
ddddd       | j                  t        |      d	d
ddddd       d d d        y # 1 sw Y   y xY w)Nrx   ry   rH  z1,2,abc,4,5,6
1,2,abc
r   1 2 3 4 5 6DEFAULT)r  restvalr   r  r   r  r   r   r   r  r   r  r   r   )r   rD   r~   r6   r  splitrN   r   r!  s      r   test_read_shortzTestDictFields.test_read_short  s    4'2 
	>gMM89LLO^^G/</B/B/D,57F T&\3U25Cc,K LT&\3U2;)2;,= >
	> 
	> 
	>s   BB$$B-c           	          g d}t        j                  |dj                               }| j                  t	        |      dddddd	       y )
N)z2147483648,43.0e12,17,abc,def
z147483648,43.0e2,17,abc,def
z47483648,43.0,170,abc,def
zi1 float i2 s1 s2r  
2147483648z43.0e1217r   rJ  )i1floati2s1s2r6   r  r>  rN   r   )r   sampler>   s      r   test_read_multizTestDictFields.test_read_multi  sO     +>+D+D+FHfl2;/3/4/4	(6 	7r   c           
          t        j                  g ddj                               }| j                  t	        |      dddddd	d
       | j                  t	        |      dddddd	d
       y )N)r.  rK   r.  r:  r  r   r  r   r  r   r   r=  rH  r   r>   s     r   test_read_with_blanksz$TestDictFields.test_read_with_blanks  st     !6+8+>+>+@B 	fSs.1#(G 	HfSs.1#(G 	Hr   c           
          t        j                  dgdj                         d      }| j                  t	        |      ddddd	d
d       y )Nz1;2;abc;4;5;6
r:  r   )r  r!   r   r  r   r  r   r   r=  rH  rL  s     r   test_read_semi_sepz!TestDictFields.test_read_semi_sep  sO    !4 5+8+>+>+@*-/ 	fSs.1#(G 	Hr   N)r   r   r   r  r  r  r  r  r  r
  r  r  r  r  r  r  r"  r%  r'  r,  r0  r5  r8  r?  rJ  rM  rO  r   r   r   r  r  "  s    ;	<?>
*1
P	188884PDP	KLOO>7HHr   r  c                   $    e Zd Zd Zd Zd Zd Zy)TestArrayWritesc           	         dd l }t        d      D cg c]  }d|z
  	 }}|j                  d|      }t        ddd      5 }t        j                  |d	      }|j                  |       d
j                  |D cg c]  }t        |       c}      dz   }|j                  d       | j                  |j                         |       d d d        y c c}w c c}w # 1 sw Y   y xY w)Nr      r   rx   ry   r+   rz   r,  rI  rJ   rK   arrayrq  r   r6   rG   r}   joinr  r~   rN   r   r   rU  r   contentsr   r   rG   rQ  s           r   test_int_writezTestArrayWrites.test_int_write  s    $)"I.qRT..KKX&4'2> 	7'ZZ9FOOAxx 3AQ 34V;HLLOW\\^X6	7 	7 / !4	7 	7s#   C 8C8C

;CCC!c           	         dd l }t        d      D cg c]
  }d|z
  dz   }}|j                  d|      }t        ddd      5 }t        j                  |d	
      }|j                  |       dj                  |D cg c]  }t        |       c}      dz   }|j                  d       | j                  |j                         |       d d d        y c c}w c c}w # 1 sw Y   y xY w)Nr   rS  皙?r   rx   ry   r+   rz   r,  rI  rJ   rK   rT  rW  s           r   test_double_writez!TestArrayWrites.test_double_write       (-b	21RT3J22KKX&4'2> 	7'ZZ9FOOAxx 3AQ 34V;HLLOW\\^X6	7 	7 3
 !4	7 	7#   C8C;C
;CCC$c           	         dd l }t        d      D cg c]
  }d|z
  dz   }}|j                  d|      }t        ddd      5 }t        j                  |d	
      }|j                  |       dj                  |D cg c]  }t        |       c}      dz   }|j                  d       | j                  |j                         |       d d d        y c c}w c c}w # 1 sw Y   y xY w)Nr   rS  r[  r  rx   ry   r+   rz   r,  rI  rJ   rK   rT  rW  s           r   test_float_writez TestArrayWrites.test_float_write  r]  r^  c                 l   dd l }dd l}|j                  d|j                        }t        ddd      5 }t	        j
                  |d      }|j                  |       d	j                  |      d
z   }|j                  d       | j                  |j                         |       d d d        y # 1 sw Y   y xY w)Nr   urx   ry   r+   rz   r,  rI  rJ   rK   )rU  stringascii_lettersr   r6   rG   r}   rV  r~   rN   r   )r   rU  rc  r   r   rG   rQ  s          r   test_char_writezTestArrayWrites.test_char_write  s    KKV1124'2> 	7'ZZ9FOOAxx{6)HLLOW\\^X6	7 	7 	7s   A.B**B3N)r   r   r   rY  r\  r`  re  r   r   r   rQ  rQ    s    
7	7	7	7r   rQ  c                   *    e Zd Zd Zd Zd Zd Zd Zy)TestDialectValidityc                 f    G d dt         j                        } |       }| j                  |j                  t         j                         d |_        | j                  t         j                  |       d|_        t         j                  |_        d|_	         |       }| j                  |j                  t         j                         | j                  |j                  d       | j                  |j                         d|_	        | j                  t         j                        5 } |        d d d        | j                  t        j                        d       d|_	        | j                  t         j                        5 } |        d d d        | j                  t        |j                        d       d|_	        | j                  t         j                        5 } |        d d d        | j                  t        |j                        d	       y # 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   GxY w)
Nc                   8    e Zd ZdZdZdZdZdZej                  Z
y)3TestDialectValidity.test_quoting.<locals>.mydialectr   ra   FTrK   Nr   r   r   r!   r.   rQ   r1   r(   r6   r9   r*   r   r   r   r<  rj  #  %    IJK##NnnGr   r<  TrL   r+   z("quotechar" must be a 1-character stringz''r  z+"quotechar" must be string or None, not int)r6   r?  rN   r*   r9   r4   r7   rQ   r8   r&   
assertTruer  r  r   r<  r   cms       r   test_quotingz TestDialectValidity.test_quoting"  s   	% 	% KCNN3 	#))Y/ $	MM	!	KCMM2c*& 	syy) 	RK	R\\*C	E #	syy) 	RK	R\\*C	E  	syy) 	RK	R\\*F	H	 		 		 	s$   #H>HH'HH$'H0c                     G d dt         j                        } |       }| j                  |j                  d       d|_        | j	                  t         j
                        5 } |        d d d        | j                  t        j                        d       d|_        | j	                  t         j
                        5 } |        d d d        | j                  t        |j                        d       d|_        | j	                  t         j
                        5 } |        d d d        | j                  t        |j                        d       d	|_        | j	                  t         j
                        5 } |        d d d        | j                  t        |j                        d
       d |_        | j	                  t         j
                        5 } |        d d d        | j                  t        |j                        d       y # 1 sw Y   xY w# 1 sw Y   NxY w# 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   axY w)Nc                   8    e Zd ZdZdZdZdZdZej                  Z
y)5TestDialectValidity.test_delimiter.<locals>.mydialectr   ra   FTrK   Nrk  r   r   r   r<  rs  K  rl  r   r<  r   :::z("delimiter" must be a 1-character stringr+      ,z%"delimiter" must be string, not bytesr  z#"delimiter" must be string, not intz("delimiter" must be string, not NoneType)r6   r?  rN   r!   r4   r7   r  r  rn  s       r   test_delimiterz"TestDialectValidity.test_delimiterJ  s   	% 	% Kc*#	syy) 	RK	R\\*C	E !	syy) 	RK	R\\*C	E #	syy) 	RK	R\\*@	B  	syy) 	RK	R\\*>	@ #	syy) 	RK	R\\*C	E5	 		 		 		 		 	s<   #H>HH4H+H7HHH(+H47I c                     G d dt         j                        } |       }| j                  |j                  d       d|_        | j	                  t         j
                  d      5   |        d d d        d|_        | j	                  t         j
                  d      5   |        d d d        d|_        | j	                  t         j
                  d      5   |        d d d        d	|_        | j	                  t         j
                  d
      5   |        d d d        y # 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   YxY w# 1 sw Y   y xY w)Nc                   8    e Zd ZdZdZdZdZdZej                  Z
y)6TestDialectValidity.test_escapechar.<locals>.mydialectr   ra   FTrK   Nrk  r   r   r   r<  ry  t  rl  r   r<  ra   r+   z)"escapechar" must be a 1-character stringz**   *z."escapechar" must be string or None, not bytesr  z,"escapechar" must be string or None, not int)r6   r?  rN   r.   r   r7   )r   r<  r   s      r   test_escapecharz#TestDialectValidity.test_escapechars  s   	% 	% Kt,!	##CII/Z[ 	K	  $	##CII/Z[ 	K	  $	##CII/_` 	K	  !	##CII/]^ 	K	 		 		 		 		 	s0   $DD&D2	D>D#&D/2D;>Ec                     G d dt         j                        } |       }| j                  |j                  d       d|_         |       }| j                  |j                  d       d|_        | j	                  t         j
                        5 } |        d d d        | j                  t        j                        d       y # 1 sw Y   /xY w)Nc                   8    e Zd ZdZdZdZdZdZej                  Z
y):TestDialectValidity.test_lineterminator.<locals>.mydialectr   ra   FTrK   Nrk  r   r   r   r<  r~    rl  r   r<  rK   rt  r  z!"lineterminator" must be a string)r6   r?  rN   r(   r4   r7   r  r  rn  s       r   test_lineterminatorz'TestDialectValidity.test_lineterminator  s    	% 	% K))62#(	 K))51#$	 syy) 	RK	R\\*<	>	 	s   CCc                 v   d }dD ]  }| j                  |      5  | j                  t        j                  ||d       | j                  t        j                  ||d       | j                  t        j                  ||d       | j                  t        j                  ||d       d d d         y # 1 sw Y   xY w)Nc                 ^     G d dt         j                        }t        || |        |       }y )Nc                       e Zd Zy)QTestDialectValidity.test_invalid_chars.<locals>.create_invalid.<locals>.mydialectNrf  r   r   r   r<  r    s    r   r<  )r6   r?  rV   )
field_namevaluer<  r   s       r   create_invalidz>TestDialectValidity.test_invalid_chars.<locals>.create_invalid  s%    CKK Iz51Ar   )r!   r.   r&   )r  r+   r      xr  )r   r4   r6   r7   )r   r  r  s      r   test_invalid_charsz&TestDialectValidity.test_invalid_chars  s    	 C 	LJ4 L!!#))^ZL!!#))^ZO!!#))^ZN!!#))^ZK	L L	LL Ls   B	B//B8	N)r   r   r   rp  rv  r{  r  r  r   r   r   rg  rg  !  s     &HP'ER6>*Lr   rg  c                       e Zd ZdZdZdZdZdZdZdZ	dZ
d	Zd
ZdZ ed      Z ed      Z ed      Z ed      ZdZd Zd Zd Zd Zd Zd Zd Zd Zy)TestSnifferzHarry's, Arlington Heights, IL, 2/1/03, Kimi Hayes
Shark City, Glendale Heights, IL, 12/28/02, Prezence
Tommy's Place, Blue Island, IL, 12/28/02, Blue Sunday/White Crow
Stonecutters Seafood and Chop House, Lemont, IL, 12/19/02, Week Back
a  'Harry''s':'Arlington Heights':'IL':'2/1/03':'Kimi Hayes'
'Shark City':'Glendale Heights':'IL':'12/28/02':'Prezence'
'Tommy''s Place':'Blue Island':'IL':'12/28/02':'Blue Sunday/White Crow'
'Stonecutters ''Seafood'' and Chop House':'Lemont':'IL':'12/19/02':'Week Back'
z+"venue","city","state","date","performers"
z05/05/03?05/05/03?05/05/03?05/05/03?05/05/03?05/05/03
05/05/03?05/05/03?05/05/03?05/05/03?05/05/03?05/05/03
05/05/03?05/05/03?05/05/03?05/05/03?05/05/03?05/05/03
zT2147483648;43.0e12;17;abc;def
147483648;43.0e2;17;abc;def
47483648;43.0;170;abc;def
zaaa	bbb
AAA	
BBB	
za|b|c
d|e|f
z'a'|'b'|'c'
'd'|e|f
z+"venue"+"city"+"state"+"date"+"performers"
zHarry's+ Arlington Heights+ IL+ 2/1/03+ Kimi Hayes
Shark City+ Glendale Heights+ IL+ 12/28/02+ Prezence
Tommy's Place+ Blue Island+ IL+ 12/28/02+ Blue Sunday/White Crow
Stonecutters Seafood and Chop House+ Lemont+ IL+ 12/19/02+ Week Back
a  'Harry''s'+ Arlington Heights'+ 'IL'+ '2/1/03'+ 'Kimi Hayes'
'Shark City'+ Glendale Heights'+' IL'+ '12/28/02'+ 'Prezence'
'Tommy''s Place'+ Blue Island'+ 'IL'+ '12/28/02'+ 'Blue Sunday/White Crow'
'Stonecutters ''Seafood'' and Chop House'+ 'Lemont'+ 'IL'+ '12/19/02'+ 'Week Back'
z|
                        abc,def
                        ghijkl,mno
                        ghi,jkl
                        z~
                        abc,def
                        ghijkl,mnop
                        ghi,jkl
                         z"time","forces"
                        1,1.5
                        0.5,5+0j
                        0,0
                        1+1j,6
                        z|"time","forces"
                        0,0
                        1,2
                        a,b
                        zabc def
ghijkl mno
ghi jkl
c                     t        j                         }| j                  |j                  | j                               | j                  |j                  | j                               y r   )r6   Snifferrm  
has_headersample12assertFalsesample13r   sniffers     r   test_issue43625zTestSniffer.test_issue43625  sE    ++-**4==9:++DMM:;r   c                     t        j                         }| j                  |j                  | j                               | j                  |j                  | j
                               y)zDMore to document existing (unexpected?) behavior than anything else.N)r6   r  r  r  sample10sample11r  s     r   test_has_header_stringsz#TestSniffer.test_has_header_strings  sG    ++-++DMM:;++DMM:;r   c                     t        j                         }| j                  |j                  | j                        d       | j                  |j                  | j
                  | j                  z         d       y NFT)r6   r  rP   r  sample1header1r  s     r   test_has_headerzTestSniffer.test_has_header  P    ++-g((6>g(()DEtLr   c                     t        j                         }| j                  |j                  | j                        d       | j                  |j                  | j
                  | j                  z         d       y r  )r6   r  rP   r  sample8header2r  s     r   'test_has_header_regex_special_delimiterz3TestSniffer.test_has_header_regex_special_delimiter  r  r   c                    t        j                         }dD ]  }| j                  |      5  |j                  |d      }| j	                  |j
                  d       | j	                  |j                  d       | j                  |j                  d       | j                  |j                  d       d d d         y # 1 sw Y   xY w)N)z	;'123;4';z'123;4';z;'123;4'z'123;4'z,;r   r>  F)
r6   r  r   sniffrN   r!   r&   rP   rQ   r1   )r   r  headerrO   s       r   test_guess_quote_and_delimiterz*TestSniffer.test_guess_quote_and_delimiter  s    ++-F 	?Ff% ?!--5  !2!2C8  !2!2C8g1159g66>? ?	?? ?s   BB99C	c                    t        j                         }|j                  | j                        }| j	                  |j
                  d       | j	                  |j                  d       | j                  |j                  d       |j                  | j                        }| j	                  |j
                  d       | j	                  |j                  d       | j                  |j                  d       y )NrJ   rL   TrM   r>  F)
r6   r  r  r  rN   r!   r&   rP   r1   sample2r   r  rO   s      r   
test_sniffzTestSniffer.test_sniff"  s    ++----**C0**C0g..5---**C0**C0g..6r   c                    t        j                         }|j                  | j                        }| j	                  |j
                  | j                         |j                  | j                  d      }| j                  |j
                  d       |j                  | j                  d      }| j                  |j
                  d       |j                  | j                        }| j                  |j
                  d       |j                  | j                        }| j                  |j
                  d       |j                  | j                        }| j                  |j
                  d       |j                  | j                        }| j                  |j
                  d       | j                  |j                  d	       |j                  | j                        }| j                  |j
                  d
       |j                  | j                        }| j                  |j
                  d
       | j                  |j                  d	       |j                  | j                        }| j                  |j
                  d       y )Nz?,)
delimiters?z/,/r   r/   r_  r>  +r   )r6   r  r  sample3r  r!   rN   sample4sample5sample6sample7r&   r  sample9sample14r  s      r   test_delimiterszTestSniffer.test_delimiters.  s   ++---- 	g''6--->**C0--->**C0---**C0---**D1---**C0---**C0**C0---**C0---**C0**C0--.**D1r   c                 H   t        j                         }|j                  | j                        }| j	                  |j
                         |j                  | j                        }| j	                  |j
                         |j                  | j                        }| j                  |j
                         |j                  | j                        }| j	                  |j
                         |j                  | j                        }| j                  |j
                         y r   )r6   r  r  r  r  rQ   r  r  rm  r  r  r  s      r   test_doublequotezTestSniffer.test_doublequoteJ  s    ++----,,----,,----++,---,,----++,r   N)r   r   r   r  r  r  r  r  r  r  r  r  r  r  r
   r  r  r  r  r  r  r  r  r  r  r  r  r  r   r   r   r  r    s    GGGGG /G"G*GGGG   H   H   H   HH<
<M
M
?
728-r   r  c                       e Zd Zd ZeZy)NULc                      y r   r   )srW   s     r   rD   z	NUL.writeX  s    r   N)r   r   r   rD   
writelinesr   r   r   r  r  W  s    Jr   r  gettotalrefcountzrequires sys.gettotalrefcount()c                   $    e Zd Zd Zd Zd Zd Zy)	TestLeaksc                    d}t        j                         }t        d      D ]  }t        j                          | j                  t        j                  g        t        j                         }t        j                  dg       t        j                  dg       t        j                  dg       ||z
  }|} | j                  |d       y )Nr   rS  a,b,c
r   
sysr  rq  gccollectrN   garbager6   r>   
assertLess)r   deltalastrcr   rcs        r   test_create_readzTestLeaks.test_create_read_  s    %%'r 	AJJLRZZ,%%'BJJ}%JJ}%JJ}%vIEF	 	q!r   c                    d}t        j                         }t               }t        d      D ]  }t	        j
                          | j                  t        j                  g        t        j                         }t        j                  |       t        j                  |       t        j                  |       ||z
  }|} | j                  |d       y )Nr   rS  r   )r  r  r  rq  r  r  rN   r  r6   rG   r  )r   r  r  r  r   r  s         r   test_create_writezTestLeaks.test_create_writen  s    %%'Er 	AJJLRZZ,%%'BJJqMJJqMJJqMvIEF	 	q!r   c                 V   d}dgdz  }t        j                         }t        d      D ]m  }t        j                          | j                  t        j                  g        t        j                         }t        j                  |      }|D ]  } ||z
  }|}o | j                  |d       y )Nr   r  r  rS  r  )r   r  r  r  r   r  rdrr  s           r   	test_readzTestLeaks.test_read~  s    }Q%%'r 	AJJLRZZ,%%'B**T"C vIEF	 	q!r   c                    d}g dgdz  }t               }t        j                         }t        d      D ]~  }t	        j
                          | j                  t        j                  g        t        j                         }t        j                  |      }|D ]  }|j                  |        ||z
  }|} | j                  |d       y )Nr   rP  r  rS  )r  r  r  rq  r  r  rN   r  r6   rG   r}   r  )	r   r  r  r  r  r   r  rG   r  s	            r   
test_writezTestLeaks.test_write  s    y{E%%'r 	AJJLRZZ,%%'BZZ]F %$%vIEF	 	q!r   N)r   r   r   r  r  r  r  r   r   r   r  r  \  s    "" " "r   r  c                        e Zd Zg dZd Zd Zy)TestUnicode)u   Martin von Löwisu   Marc André LemburgzGuido van Rossumu   François Pinardc                 <   t        ddd      5 }|j                  dj                  | j                        dz          |j	                  d       t        j                  |      }| j                  t        |      | j                  g       d d d        y # 1 sw Y   y xY wNrx   r+   ry   rO  rJ   rK   r   )	r   rD   rV  namesr~   r6   r>   rN   r   r!  s      r   test_unicode_readzTestUnicode.test_unicode_read  sv    4g> 	9'MM#((4::.78LLOZZ(FT&\DJJ<8		9 	9 	9s   A:BBc                 H   t        ddd      5 }t        j                  |      }|j                  | j                         dj                  | j                        dz   }|j                  d       | j                  |j                         |       d d d        y # 1 sw Y   y xY wr  )	r   r6   rG   r}   r  rV  r~   rN   r   )r   r   rG   rQ  s       r   test_unicode_writezTestUnicode.test_unicode_write  s{    4g> 	7'ZZ(FOODJJ'xx

+F2HLLOW\\^X6	7 	7 	7s   B BB!N)r   r   r   r  r  r  r   r   r   r  r    s    !E
97r   r  c                       e Zd Zd Zd Zy)KeyOrderingTestc                    t               }t        d      D ]  }t        ddd      5 }t        j                  ||      }|j                          |j                  d       t        j                  |      }t        |j                        }| j                  ||       |j                  |       d d d         | j                  t        |      dd       y # 1 sw Y   xY w)	Nabcderx   r+   ry   rO  r   x   z@Key ordering: some key permutations not collected (expected 120))setr	   r   r6   r  r  r~   r  tupler  rN   addlen)r   	resultsetkeys
fileobjectdwdrkts          r   ,test_ordering_for_the_dict_reader_and_writerz<KeyOrderingTest.test_ordering_for_the_dict_reader_and_writer  s    E	 ) 	"DtR'B "j^^J5 "^^J/2==)  r*b!" "	" 	Y.pq" "s   BCC	c                    t        d      j                         }| j                  t        t	        j
                  |            t        ddg      t        ddd ddgfg      t        dd	g      t        d
dg      g       | j                  t        t	        j
                  |d            t        ddg      t        dddddgfg      t        dd	g      t        d
dg      g       |d= | j                  t        t	        j
                  |ddg            t        ddg      t        ddd ddgfg      t        ddg      t        ddg      g       y )Nz            FirstName,LastName
            Eric,Idle
            Graham,Chapman,Over1,Over2

            Under1
            John,Cleese
        )	FirstNameEric)LastNameIdle)r  Graham)r  ChapmanOver1Over2)r  Under1)r  N)r  John)r  Cleese	OtherInfor7  r   fnamelnamer  )r  r  )r  r  )r  r  )r  r  )r  r  )r  N)r  r  )r  r  )r
   
splitlinesrN   r   r6   r  r   )r   datas     r   test_ordered_dict_readerz(KeyOrderingTest.test_ordered_dict_reader  s      Z\ 	 	cnnT23/1EFG13J'7!346 713EFG/1GHI		 	cnnT;GH/1EFG13J&'(:;= >13EFG/1GHI		 GcnnTw>PQR+->?@-/C'7!346 7-?@+-@AB		r   N)r   r   r   r  r  r   r   r   r  r    s    r!r   r  c                   <    e Zd Zd Zd Zej                  d        Zy)MiscTestCasec                 F    ddh}t        j                  | t        d|       y )Nr  __version__)r6   _csv)extra)r   check__all__r6   )r   r  s     r   test__all__zMiscTestCase.test__all__  s     M*T3uEr   c                 6     G d dt         j                        }y )Nc                       e Zd Zy)+MiscTestCase.test_subclassable.<locals>.FooNrf  r   r   r   Foor    s    r   r	  )r6   r7   )r   r	  s     r   test_subclassablezMiscTestCase.test_subclassable  s    !#))!r   c                     t        j                  d      }|j                  |j                  fD ])  }| j	                  |      5  t        | |       d d d        + y # 1 sw Y   6xY w)Nr  )tp)r   import_moduleReaderWriterr   r   )r   r  r  s      r   test_disallow_instantiationz(MiscTestCase.test_disallow_instantiation  s`    **62++t{{* 	7B$ 7,T267 7	77 7s   AA$	N)r   r   r   r  r
  r   r  r  r   r   r   r  r    s'    F" 7 7r   r  __main__)/rn  r  unittestior   tempfiler   r6   r  rr  testr   test.supportr   r   r   r)  r	   textwrapr
   collectionsr   r   TestCaser   r  rx  r  r,  r  r  r  r  r  r  rQ  rg  r  r  
skipUnlesshasattrr  r  r  r  r   mainr   r   r   <module>r     s    
   " 
 	   U U "  # 
f7x   f7RKK(++ KKZ>(## > _O{ _OB399 ?{ ?Sk S A[ AOHX&& OHb,7h'' ,7\NL(++ NLbc-(## c-J 
 WS"4568?"!! ?"8?"B7(## 7.1h'' 1h78$$ 7  zHMMO r   