@@ -2082,11 +2082,10 @@ def test_schema(tmpdir, options, expected):
2082
2082
def test_long_csv_column_value (tmpdir ):
2083
2083
db_path = str (tmpdir / "test.db" )
2084
2084
csv_path = str (tmpdir / "test.csv" )
2085
- csv_file = open (csv_path , "w" )
2086
- long_string = "a" * 131073
2087
- csv_file .write ("id,text\n " )
2088
- csv_file .write ("1,{}\n " .format (long_string ))
2089
- csv_file .close ()
2085
+ with open (csv_path , "w" ) as csv_file :
2086
+ long_string = "a" * 131073
2087
+ csv_file .write ("id,text\n " )
2088
+ csv_file .write ("1,{}\n " .format (long_string ))
2090
2089
result = CliRunner ().invoke (
2091
2090
cli .cli ,
2092
2091
["insert" , db_path , "bigtable" , csv_path , "--csv" ],
@@ -2110,11 +2109,10 @@ def test_long_csv_column_value(tmpdir):
2110
2109
def test_import_no_headers (tmpdir , args , tsv ):
2111
2110
db_path = str (tmpdir / "test.db" )
2112
2111
csv_path = str (tmpdir / "test.csv" )
2113
- csv_file = open (csv_path , "w" )
2114
- sep = "\t " if tsv else ","
2115
- csv_file .write ("Cleo{sep}Dog{sep}5\n " .format (sep = sep ))
2116
- csv_file .write ("Tracy{sep}Spider{sep}7\n " .format (sep = sep ))
2117
- csv_file .close ()
2112
+ with open (csv_path , "w" ) as csv_file :
2113
+ sep = "\t " if tsv else ","
2114
+ csv_file .write ("Cleo{sep}Dog{sep}5\n " .format (sep = sep ))
2115
+ csv_file .write ("Tracy{sep}Spider{sep}7\n " .format (sep = sep ))
2118
2116
result = CliRunner ().invoke (
2119
2117
cli .cli ,
2120
2118
["insert" , db_path , "creatures" , csv_path ] + args ,
0 commit comments