-
Notifications
You must be signed in to change notification settings - Fork 96
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add marker for DuckDb-only tests (#1565)
This PR adds a `pytest` marker that allows tests to only be run when testing using DuckDB. This is useful in integration test cases where engine-specific SQL rendering is not being tested. This can help to reduce test suite runtimes and to reduce the number of snapshots.
- Loading branch information
Showing
2 changed files
with
46 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
from __future__ import annotations | ||
|
||
import logging | ||
|
||
import pytest | ||
|
||
from metricflow.protocols.sql_client import SqlClient, SqlEngine | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
@pytest.mark.duckdb_only | ||
def test_duckdb_only(sql_client: SqlClient) -> None: | ||
"""Check that the `duckdb_only` skips tests when the tests are run with another SQL engine. | ||
This depends on auto-using of the `skip_if_not_duck_db` fixture. | ||
""" | ||
duckdb_engine_type = SqlEngine.DUCKDB | ||
engine_type_under_test = sql_client.sql_engine_type | ||
assert engine_type_under_test is duckdb_engine_type, ( | ||
f"This test should have only been run when using {duckdb_engine_type}, but the engine type under test is" | ||
f" {engine_type_under_test}" | ||
) |