From 2b1578b24df9368e2f93f5e3e2eb4a5cd4d53f7f Mon Sep 17 00:00:00 2001 From: dave Date: Wed, 4 Sep 2024 11:32:00 +0200 Subject: [PATCH] only import sqlalchemy in tests if present --- tests/load/sources/sql_database/conftest.py | 9 +++++++-- .../sql_database/test_sql_database_pipeline_template.py | 1 + 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/tests/load/sources/sql_database/conftest.py b/tests/load/sources/sql_database/conftest.py index 6b6d1b3946..3a0a933af6 100644 --- a/tests/load/sources/sql_database/conftest.py +++ b/tests/load/sources/sql_database/conftest.py @@ -1,10 +1,15 @@ -from typing import Iterator +from typing import Iterator, Any import pytest import dlt from dlt.sources.credentials import ConnectionStringCredentials -from tests.load.sources.sql_database.sql_source import SQLAlchemySourceDB + +try: + from tests.load.sources.sql_database.sql_source import SQLAlchemySourceDB +except ModuleNotFoundError: + SQLAlchemySourceDB = Any + pytest.skip("test needs sql_alchemy") def _create_db(**kwargs) -> Iterator[SQLAlchemySourceDB]: diff --git a/tests/sources/sql_database/test_sql_database_pipeline_template.py b/tests/sources/sql_database/test_sql_database_pipeline_template.py index e167a42597..88c05ea333 100644 --- a/tests/sources/sql_database/test_sql_database_pipeline_template.py +++ b/tests/sources/sql_database/test_sql_database_pipeline_template.py @@ -1,5 +1,6 @@ import pytest + # TODO: not all template functions are tested here # we may be able to test more in tests/load/sources @pytest.mark.parametrize(