Skip to content

Commit 735cf0a

Browse files
committed
Making tests pass
1 parent ed90ded commit 735cf0a

File tree

9 files changed

+15
-24
lines changed

9 files changed

+15
-24
lines changed

tests/conftest.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import warnings
44
from importlib import import_module
55
from pathlib import Path
6-
from typing import Any
6+
from typing import Any, Union
77

88
import pytest
99

@@ -188,7 +188,7 @@ def __getattr__(self, name: str) -> Any: # noqa: ANN401
188188

189189
@pytest.fixture
190190
def require():
191-
def _require(extension_name, db_name="") -> duckdb.DuckDBPyConnection | None:
191+
def _require(extension_name, db_name="") -> Union[duckdb.DuckDBPyConnection, None]:
192192
# Paths to search for extensions
193193

194194
build = Path(__file__).parent.parent / "build"

tests/fast/api/test_connection_close.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def check_exception(f):
1717

1818
class TestConnectionClose:
1919
def test_connection_close(self, duckdb_cursor):
20-
with tempfile.NamedTemporaryFile(delete=False) as tmp:
20+
with tempfile.NamedTemporaryFile() as tmp:
2121
db = tmp.name
2222
con = duckdb.connect(db)
2323
cursor = con.cursor()
@@ -32,7 +32,7 @@ def test_open_and_exit(self):
3232
raise TypeError()
3333

3434
def test_reopen_connection(self, duckdb_cursor):
35-
with tempfile.NamedTemporaryFile(delete=False) as tmp:
35+
with tempfile.NamedTemporaryFile() as tmp:
3636
db = tmp.name
3737
con = duckdb.connect(db)
3838
cursor = con.cursor()

tests/fast/api/test_dbapi11.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def check_exception(f):
1616

1717
class TestReadOnly:
1818
def test_readonly(self, duckdb_cursor):
19-
with tempfile.NamedTemporaryFile(delete=False) as tmp:
19+
with tempfile.NamedTemporaryFile() as tmp:
2020
db = tmp.name
2121

2222
# this is forbidden

tests/fast/arrow/test_12384.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
def test_10795():
1111
arrow_filename = Path(__file__).parent / "data" / "arrow_table"
12-
with pa.memory_map(arrow_filename, "r") as source:
12+
with pa.memory_map(str(arrow_filename), "r") as source:
1313
reader = pa.ipc.RecordBatchFileReader(source)
1414
taxi_fhvhv_arrow = reader.read_all()
1515
con = duckdb.connect(database=":memory:")

tests/fast/arrow/test_unregister.py

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,11 @@
66

77
import duckdb
88

9-
try:
10-
import pyarrow
11-
import pyarrow.parquet
12-
13-
can_run = True
14-
except Exception:
15-
can_run = False
16-
9+
pyarrow = pytest.importorskip("pyarrow")
10+
pytest.importorskip("pyarrow.parquet")
1711

1812
class TestArrowUnregister:
1913
def test_arrow_unregister1(self, duckdb_cursor):
20-
if not can_run:
21-
return
2214
parquet_filename = str(Path(__file__).parent / "data" / "userdata1.parquet")
2315
arrow_table_obj = pyarrow.parquet.read_table(parquet_filename)
2416
connection = duckdb.connect(":memory:")
@@ -33,11 +25,8 @@ def test_arrow_unregister1(self, duckdb_cursor):
3325
connection.execute("DROP VIEW IF EXISTS arrow_table;")
3426

3527
def test_arrow_unregister2(self, duckdb_cursor):
36-
if not can_run:
37-
return
38-
fd, db = tempfile.mkstemp()
39-
os.close(fd)
40-
os.remove(db)
28+
with tempfile.NamedTemporaryFile() as tmp:
29+
db = tmp.name
4130

4231
connection = duckdb.connect(db)
4332
parquet_filename = str(Path(__file__).parent / "data" / "userdata1.parquet")

tests/fast/pandas/test_pandas_unregister.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def test_pandas_unregister1(self, duckdb_cursor, pandas):
2424

2525
@pytest.mark.parametrize("pandas", [NumpyPandas(), ArrowPandas()])
2626
def test_pandas_unregister2(self, duckdb_cursor, pandas):
27-
with tempfile.NamedTemporaryFile(delete=False) as tmp:
27+
with tempfile.NamedTemporaryFile() as tmp:
2828
db = tmp.name
2929

3030
connection = duckdb.connect(db)

tests/fast/relational_api/test_rapi_description.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import duckdb
12
import pytest
23

34

tests/fast/spark/test_spark_filter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ def test_dataframe_filter(self, spark):
9999
assert item.state != "OH"
100100
assert item.state != "NY"
101101

102-
df2 = df.filter(not df.state.isin(li))
102+
df2 = df.filter(df.state.isin(li) == False) # noqa: E712
103103
res2 = df2.collect()
104104
assert res2 == res
105105

tests/fast/udf/test_remove_function.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ def func(x: str) -> str:
5757

5858
with pytest.raises(duckdb.BinderException, match="No function matches the given name"):
5959
con.sql("select func(42)")
60-
con.sql("select func('test'::VARCHAR)")
60+
61+
rel2 = con.sql("select func('test'::VARCHAR)")
6162
con.remove_function("func")
6263

6364
def also_func(x: int) -> int:

0 commit comments

Comments
 (0)