Skip to content

Commit c6fbcb5

Browse files
committed
fix tests
1 parent 833ecbe commit c6fbcb5

File tree

6 files changed

+35
-37
lines changed

6 files changed

+35
-37
lines changed

tests/fast/api/test_3728.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ def test_3728_describe_enum(self, duckdb_cursor):
1414

1515
# This fails with "RuntimeError: Not implemented Error: unsupported type: mood"
1616
assert cursor.table("person").execute().description == [
17-
('name', 'STRING', None, None, None, None, None),
17+
('name', 'VARCHAR', None, None, None, None, None),
1818
('current_mood', "ENUM('sad', 'ok', 'happy')", None, None, None, None, None),
1919
]

tests/fast/api/test_dbapi10.py

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
11
# cursor description
22
from datetime import datetime, date
33
from pytest import mark
4+
import duckdb
45

56

67
class TestCursorDescription(object):
78
@mark.parametrize(
89
"query,column_name,string_type,real_type",
910
[
10-
["SELECT * FROM integers", "i", "NUMBER", int],
11-
["SELECT * FROM timestamps", "t", "DATETIME", datetime],
12-
["SELECT DATE '1992-09-20' AS date_col;", "date_col", "Date", date],
13-
["SELECT '\\xAA'::BLOB AS blob_col;", "blob_col", "BINARY", bytes],
14-
["SELECT {'x': 1, 'y': 2, 'z': 3} AS struct_col", "struct_col", "dict", dict],
15-
["SELECT [1, 2, 3] AS list_col", "list_col", "list", list],
16-
["SELECT 'Frank' AS str_col", "str_col", "STRING", str],
11+
["SELECT * FROM integers", "i", "INTEGER", int],
12+
["SELECT * FROM timestamps", "t", "TIMESTAMP", datetime],
13+
["SELECT DATE '1992-09-20' AS date_col;", "date_col", "DATE", date],
14+
["SELECT '\\xAA'::BLOB AS blob_col;", "blob_col", "BLOB", bytes],
15+
["SELECT {'x': 1, 'y': 2, 'z': 3} AS struct_col", "struct_col", "STRUCT(x INTEGER, y INTEGER, z INTEGER)", dict],
16+
["SELECT [1, 2, 3] AS list_col", "list_col", "INTEGER[]", list],
17+
["SELECT 'Frank' AS str_col", "str_col", "VARCHAR", str],
1718
["SELECT [1, 2, 3]::JSON AS json_col", "json_col", "JSON", str],
1819
["SELECT union_value(tag := 1) AS union_col", "union_col", "UNION(tag INTEGER)", int],
1920
],
@@ -23,6 +24,24 @@ def test_description(self, query, column_name, string_type, real_type, duckdb_cu
2324
assert duckdb_cursor.description == [(column_name, string_type, None, None, None, None, None)]
2425
assert isinstance(duckdb_cursor.fetchone()[0], real_type)
2526

27+
def test_description_comparisons(self):
28+
duckdb.execute("select 42 a, 'test' b, true c")
29+
types = [x[1] for x in duckdb.description()]
30+
31+
STRING = duckdb.STRING
32+
NUMBER = duckdb.NUMBER
33+
DATETIME = duckdb.DATETIME
34+
35+
assert(types[1] == STRING)
36+
assert(STRING == types[1])
37+
assert(types[0] != STRING)
38+
assert((types[1] != STRING) == False)
39+
assert((STRING != types[1]) == False)
40+
41+
assert(types[1] in [STRING])
42+
assert(types[1] in [STRING, NUMBER])
43+
assert(types[1] not in [NUMBER, DATETIME])
44+
2645
def test_none_description(self, duckdb_empty_cursor):
2746
assert duckdb_empty_cursor.description is None
2847

tests/fast/api/test_duckdb_connection.py

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -117,25 +117,6 @@ def test_readonly_properties(self):
117117
assert description == [('42', 'INTEGER', None, None, None, None, None)]
118118
assert rowcount == -1
119119

120-
def test_description(self):
121-
duckdb.execute("select 42 a, 'test' b, true c")
122-
types = [x[1] for x in duckdb.description()]
123-
124-
STRING = duckdb.STRING
125-
NUMBER = duckdb.NUMBER
126-
DATETIME = duckdb.DATETIME
127-
128-
assert(types[1] == STRING)
129-
assert(STRING == types[1])
130-
assert(types[0] != STRING)
131-
assert((types[1] != STRING) == False)
132-
assert((STRING != types[1]) == False)
133-
134-
assert(types[1] in [STRING])
135-
assert(types[1] in [STRING, NUMBER])
136-
assert(types[1] not in [NUMBER, DATETIME])
137-
138-
139120
def test_execute(self):
140121
assert [([4, 2],)] == duckdb.execute("select [4,2]").fetchall()
141122

@@ -369,9 +350,6 @@ def test_view(self):
369350
assert [([0, 1, 2, 3, 4],)] == duckdb.view("vw").fetchall()
370351
duckdb.execute("drop view vw")
371352

372-
def test_description(self):
373-
assert None != duckdb.description
374-
375353
def test_close(self):
376354
assert None != duckdb.close
377355

tests/fast/relational_api/test_rapi_description.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ def test_rapi_description(self, duckdb_cursor):
99
names = [x[0] for x in desc]
1010
types = [x[1] for x in desc]
1111
assert names == ['a', 'b']
12-
assert types == ['NUMBER', 'NUMBER']
12+
assert types == ['INTEGER', 'BIGINT']
13+
assert (all([x == duckdb.NUMBER for x in types]))
1314

1415
def test_rapi_describe(self, duckdb_cursor):
1516
np = pytest.importorskip("numpy")

tests/fast/test_map.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,9 +154,9 @@ def cast_to_string(df):
154154

155155
con = duckdb.connect()
156156
rel = con.sql('select i from range (10) tbl(i)')
157-
assert rel.types[0] == int
157+
assert rel.types[0] == duckdb.NUMBER
158158
mapped_rel = rel.map(cast_to_string, schema={'i': str})
159-
assert mapped_rel.types[0] == str
159+
assert mapped_rel.types[0] == duckdb.STRING
160160

161161
def test_explicit_schema_returntype_mismatch(self):
162162
def does_nothing(df):

tests/fast/test_result.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ def test_result_describe_types(self, duckdb_cursor):
3131
rel = connection.table("test")
3232
res = rel.execute()
3333
assert res.description == [
34-
('i', 'bool', None, None, None, None, None),
35-
('j', 'Time', None, None, None, None, None),
36-
('k', 'STRING', None, None, None, None, None),
34+
('i', 'BOOLEAN', None, None, None, None, None),
35+
('j', 'TIME', None, None, None, None, None),
36+
('k', 'VARCHAR', None, None, None, None, None),
3737
]
3838

3939
def test_result_timestamps(self, duckdb_cursor):
@@ -64,7 +64,7 @@ def test_result_interval(self):
6464

6565
rel = connection.table("intervals")
6666
res = rel.execute()
67-
assert res.description == [('ivals', 'TIMEDELTA', None, None, None, None, None)]
67+
assert res.description == [('ivals', 'INTERVAL', None, None, None, None, None)]
6868
assert res.fetchall() == [
6969
(datetime.timedelta(days=1.0),),
7070
(datetime.timedelta(seconds=2.0),),

0 commit comments

Comments
 (0)