File tree 1 file changed +19
-0
lines changed
1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -211,6 +211,25 @@ def write(self, buf):
211
211
fileobj .seek (0 )
212
212
self .assertEqual (fileobj .read (), "a,b\r \n c,d\r \n " )
213
213
214
+ def test_writerows_with_none (self ):
215
+ with TemporaryFile ("w+" , newline = '' ) as fileobj :
216
+ writer = csv .writer (fileobj )
217
+ writer .writerows ([['a' ,None ],[None ,'d' ]])
218
+ fileobj .seek (0 )
219
+ self .assertEqual (fileobj .read (), "a,\r \n ,d\r \n " )
220
+
221
+ with TemporaryFile ("w+" , newline = '' ) as fileobj :
222
+ writer = csv .writer (fileobj )
223
+ writer .writerows ([[None ],['a' ]])
224
+ fileobj .seek (0 )
225
+ self .assertEqual (fileobj .read (), '""\r \n a\r \n ' )
226
+
227
+ with TemporaryFile ("w+" , newline = '' ) as fileobj :
228
+ writer = csv .writer (fileobj )
229
+ writer .writerows ([['a' ],[None ]])
230
+ fileobj .seek (0 )
231
+ self .assertEqual (fileobj .read (), 'a\r \n ""\r \n ' )
232
+
214
233
@support .cpython_only
215
234
def test_writerows_legacy_strings (self ):
216
235
import _testcapi
You can’t perform that action at this time.
0 commit comments