@@ -37,11 +37,14 @@ def test_read_json_sample_size(self):
3737 assert res == (1 , "O Brother, Where Art Thou?" )
3838
3939 def test_read_json_format (self ):
40+ # Use a dedicated connection: a binder error now invalidates the active transaction, and the shared
41+ # default connection can carry an open transaction from a previous test's unexhausted fetchone().
42+ con = duckdb .connect ()
4043 # Wrong option
4144 with pytest .raises (duckdb .BinderException , match = r"format must be one of .* not 'test'" ):
42- rel = duckdb .read_json (TestFile ("example.json" ), format = "test" )
45+ rel = con .read_json (TestFile ("example.json" ), format = "test" )
4346
44- rel = duckdb .read_json (TestFile ("example.json" ), format = "unstructured" )
47+ rel = con .read_json (TestFile ("example.json" ), format = "unstructured" )
4548 res = rel .fetchone ()
4649 print (res )
4750 assert res == (
@@ -72,11 +75,13 @@ def test_read_filelike(self, duckdb_cursor):
7275 assert res [0 ][2 ] != res [1 ][2 ]
7376
7477 def test_read_json_records (self ):
78+ # Dedicated connection (see test_read_json_format): avoid inheriting a poisoned transaction.
79+ con = duckdb .connect ()
7580 # Wrong option
7681 with pytest .raises (duckdb .BinderException , match = """read_json requires "records" to be one of""" ):
77- rel = duckdb .read_json (TestFile ("example.json" ), records = "none" )
82+ rel = con .read_json (TestFile ("example.json" ), records = "none" )
7883
79- rel = duckdb .read_json (TestFile ("example.json" ), records = "true" )
84+ rel = con .read_json (TestFile ("example.json" ), records = "true" )
8085 res = rel .fetchone ()
8186 print (res )
8287 assert res == (1 , "O Brother, Where Art Thou?" )
0 commit comments