Skip to content

Commit 1c7ee57

Browse files
authored
Merge pull request #1246 from Mause/variable-user-agent
test: handle user agent including python version
2 parents 2dc7743 + 954c877 commit 1c7ee57

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

duckdb_engine/tests/test_basic.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -525,6 +525,9 @@ def test_url_config_and_dict_config() -> None:
525525
assert memory_limit in ("500.0MB", "476.8 MiB")
526526

527527

528+
user_agent_re = r"duckdb/.*(.*) python(/.*)? duckdb_engine/.*(sqlalchemy/.*)"
529+
530+
528531
@mark.skipif(
529532
supports_user_agent is False,
530533
reason="custom_user_agent is not supported for DuckDB version < 0.9.2",
@@ -536,7 +539,7 @@ def test_user_agent() -> None:
536539
res = conn.execute(text("PRAGMA USER_AGENT"))
537540
row = res.first()
538541
assert row is not None
539-
assert re.match(r"duckdb/.*(.*) python duckdb_engine/.*(sqlalchemy/.*)", row[0])
542+
assert re.match(user_agent_re, row[0])
540543

541544

542545
@mark.skipif(
@@ -551,9 +554,7 @@ def test_user_agent_with_custom_user_agent() -> None:
551554
res = conn.execute(text("PRAGMA USER_AGENT"))
552555
row = res.first()
553556
assert row is not None
554-
assert re.match(
555-
r"duckdb/.*(.*) python duckdb_engine/.*(sqlalchemy/.*) custom", row[0]
556-
)
557+
assert re.match(user_agent_re + " custom", row[0])
557558

558559
# Check that connect hasn't mutated the caller's data.
559560
assert connect_args["config"]["custom_user_agent"] == "custom"

0 commit comments

Comments
 (0)