@@ -49,8 +49,9 @@ def _test_arg_valid(self, ctor, arg):
4949 self .assertRaises (TypeError , ctor , arg , quoting = None )
5050 self .assertRaises (TypeError , ctor , arg ,
5151 quoting = csv .QUOTE_ALL , quotechar = '' )
52- self .assertRaises (TypeError , ctor , arg ,
53- quoting = csv .QUOTE_ALL , quotechar = None )
52+ for quoting in csv .QUOTE_ALL , csv .QUOTE_STRINGS , csv .QUOTE_NOTNULL :
53+ self .assertRaises (TypeError , ctor , arg ,
54+ quoting = quoting , quotechar = None )
5455 self .assertRaises (TypeError , ctor , arg ,
5556 quoting = csv .QUOTE_NONE , quotechar = '' )
5657 self .assertRaises (ValueError , ctor , arg , delimiter = '\n ' )
@@ -259,6 +260,22 @@ def test_write_escape(self):
259260 self ._write_test (['C\\ ' , '6' , '7' , 'X"' ], 'C\\ \\ ,6,7,"X"""' ,
260261 escapechar = '\\ ' , quoting = csv .QUOTE_MINIMAL )
261262
263+ def test_write_quote_styles_escape (self ):
264+ self ._write_test (['a"b' , 'x\\ y' , 1 , None ],
265+ '"a""b","x\\ \\ y",1,' ,
266+ quoting = csv .QUOTE_STRINGS , escapechar = '\\ ' )
267+ self ._write_test (['a"b' , 'x\\ y' , 1 , None ],
268+ '"a\\ "b","x\\ \\ y",1,' ,
269+ quoting = csv .QUOTE_STRINGS , escapechar = '\\ ' ,
270+ doublequote = False )
271+ self ._write_test (['a"b' , 'x\\ y' , 1 , None ],
272+ '"a""b","x\\ \\ y","1",' ,
273+ quoting = csv .QUOTE_NOTNULL , escapechar = '\\ ' )
274+ self ._write_test (['a"b' , 'x\\ y' , 1 , None ],
275+ '"a\\ "b","x\\ \\ y","1",' ,
276+ quoting = csv .QUOTE_NOTNULL , escapechar = '\\ ' ,
277+ doublequote = False )
278+
262279 def test_write_lineterminator (self ):
263280 for lineterminator in '\r \n ' , '\n ' , '\r ' , '!@#' , '\0 ' :
264281 with self .subTest (lineterminator = lineterminator ):
0 commit comments