mirror of
https://github.com/hwchase17/langchain.git
synced 2025-07-07 13:40:46 +00:00
Suppress duckdb warning in unit tests explicitly (#3653)
This catches the warning raised when using duckdb, asserts that it's as expected. The goal is to resolve all existing warnings to make unit-testing much stricter.
This commit is contained in:
parent
2052e70664
commit
c5a4b4fea1
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
Using DuckDB as SQLite does not support schemas.
|
Using DuckDB as SQLite does not support schemas.
|
||||||
"""
|
"""
|
||||||
|
import pytest
|
||||||
|
|
||||||
from sqlalchemy import (
|
from sqlalchemy import (
|
||||||
Column,
|
Column,
|
||||||
@ -70,7 +71,22 @@ def test_sql_database_run() -> None:
|
|||||||
stmt = insert(user).values(user_id=13, user_name="Harrison")
|
stmt = insert(user).values(user_id=13, user_name="Harrison")
|
||||||
with engine.begin() as conn:
|
with engine.begin() as conn:
|
||||||
conn.execute(stmt)
|
conn.execute(stmt)
|
||||||
db = SQLDatabase(engine, schema="schema_a")
|
|
||||||
|
with pytest.warns(Warning) as records:
|
||||||
|
db = SQLDatabase(engine, schema="schema_a")
|
||||||
|
|
||||||
|
# Metadata creation with duckdb raises a warning at the moment about reflection.
|
||||||
|
# As a stop-gap to increase strictness of pytest to fail on warnings, we'll
|
||||||
|
# explicitly catch the warning and assert that it's the one we expect.
|
||||||
|
# We may need to revisit at a later stage and determine why a warning is being
|
||||||
|
# raised here.
|
||||||
|
assert len(records) == 1
|
||||||
|
assert isinstance(records[0].message, Warning)
|
||||||
|
assert (
|
||||||
|
records[0].message.args[0]
|
||||||
|
== "duckdb-engine doesn't yet support reflection on indices"
|
||||||
|
)
|
||||||
|
|
||||||
command = 'select user_name from "user" where user_id = 13'
|
command = 'select user_name from "user" where user_id = 13'
|
||||||
output = db.run(command)
|
output = db.run(command)
|
||||||
expected_output = "[('Harrison',)]"
|
expected_output = "[('Harrison',)]"
|
||||||
|
Loading…
Reference in New Issue
Block a user