|
2 | 2 |
|
3 | 3 | import os
|
4 | 4 | import sqlite3
|
5 |
| -import tempfile |
6 | 5 | from pathlib import Path
|
7 | 6 |
|
8 | 7 | import duckdb
|
@@ -137,32 +136,6 @@ def test_read_json(con, data_dir, tmp_path):
|
137 | 136 | assert nrows == jst.count().execute()
|
138 | 137 |
|
139 | 138 |
|
140 |
| -def test_temp_directory(tmp_path): |
141 |
| - query = "SELECT current_setting('temp_directory')" |
142 |
| - |
143 |
| - # 1. in-memory + no temp_directory specified |
144 |
| - con = ibis.duckdb.connect() |
145 |
| - |
146 |
| - value = con.raw_sql(query).fetchone()[0] |
147 |
| - assert value # we don't care what the specific value is |
148 |
| - |
149 |
| - temp_directory = Path(tempfile.gettempdir()) / "duckdb" |
150 |
| - |
151 |
| - # 2. in-memory + temp_directory specified |
152 |
| - con = ibis.duckdb.connect(temp_directory=temp_directory) |
153 |
| - value = con.raw_sql(query).fetchone()[0] |
154 |
| - assert value == str(temp_directory) |
155 |
| - |
156 |
| - # 3. on-disk + no temp_directory specified |
157 |
| - # untested, duckdb sets the temp_directory to something implementation |
158 |
| - # defined |
159 |
| - |
160 |
| - # 4. on-disk + temp_directory specified |
161 |
| - con = ibis.duckdb.connect(tmp_path / "test2.ddb", temp_directory=temp_directory) |
162 |
| - value = con.raw_sql(query).fetchone()[0] |
163 |
| - assert value == str(temp_directory) |
164 |
| - |
165 |
| - |
166 | 139 | @pytest.fixture(scope="session")
|
167 | 140 | def pgurl(): # pragma: no cover
|
168 | 141 | pgcon = ibis.postgres.connect(
|
@@ -381,10 +354,16 @@ def test_memtable_with_nullable_pyarrow_not_string(con):
|
381 | 354 | assert len(res) == len(data)
|
382 | 355 |
|
383 | 356 |
|
384 |
| -def test_set_temp_dir(tmp_path): |
385 |
| - path = tmp_path / "foo" / "bar" |
386 |
| - ibis.duckdb.connect(temp_directory=path) |
387 |
| - assert path.exists() |
| 357 | +@pytest.mark.parametrize( |
| 358 | + "database", |
| 359 | + [lambda parent: parent / "test.ddb", lambda _: ":memory:"], |
| 360 | + ids=["disk", "memory"], |
| 361 | +) |
| 362 | +def test_temp_dir_set(tmp_path, database): |
| 363 | + temp_directory = tmp_path / "does" / "not" / "exist" |
| 364 | + temp_directory.mkdir(parents=True, exist_ok=True) |
| 365 | + con = ibis.duckdb.connect(database(tmp_path), temp_directory=temp_directory) |
| 366 | + assert con.settings["temp_directory"] == str(temp_directory) |
388 | 367 |
|
389 | 368 |
|
390 | 369 | @pytest.mark.xfail(
|
|
0 commit comments