diff --git a/tests/conftest.py b/tests/conftest.py index 84f894f707..c47a4fee9a 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1117,6 +1117,16 @@ def langchain_nvidia_ai_endpoints_fixture(fail_missing: bool): fail_missing=fail_missing) +@pytest.fixture(name="databricks", scope='session') +def databricks_fixture(fail_missing: bool): + """ + Fixture to ensure databricks is installed + """ + yield import_or_skip("databricks.connect", + reason=OPT_DEP_SKIP_REASON.format(package="databricks-connect"), + fail_missing=fail_missing) + + @pytest.mark.usefixtures("openai") @pytest.fixture(name="mock_chat_completion") def mock_chat_completion_fixture(): diff --git a/tests/morpheus/stages/databricks/conftest.py b/tests/morpheus/stages/databricks/conftest.py new file mode 100644 index 0000000000..3d602715e3 --- /dev/null +++ b/tests/morpheus/stages/databricks/conftest.py @@ -0,0 +1,25 @@ +# SPDX-FileCopyrightText: Copyright (c) 2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import pytest + + +# Override fixtures from parent setting autouse to True +@pytest.fixture(name="databricks", autouse=True, scope='session') +def databricks_fixture(databricks): + """ + All of the tests in this subdir require databricks + """ + yield databricks diff --git a/tests/morpheus/stages/test_databricks_deltalake_source_stage.py b/tests/morpheus/stages/databricks/test_databricks_deltalake_source_stage.py similarity index 93% rename from tests/morpheus/stages/test_databricks_deltalake_source_stage.py rename to tests/morpheus/stages/databricks/test_databricks_deltalake_source_stage.py index d573234a31..e7d777b0a1 100644 --- a/tests/morpheus/stages/test_databricks_deltalake_source_stage.py +++ b/tests/morpheus/stages/databricks/test_databricks_deltalake_source_stage.py @@ -12,12 +12,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -try: - import databricks.connect # pylint: disable=unused-import # noqa -except ImportError: - import pytest - pytest.skip("databricks-connect not installed", allow_module_level=True) - from unittest.mock import patch from _utils import assert_results diff --git a/tests/morpheus/stages/test_write_to_databricks_deltalake_stage.py b/tests/morpheus/stages/databricks/test_write_to_databricks_deltalake_stage.py similarity index 93% rename from tests/morpheus/stages/test_write_to_databricks_deltalake_stage.py rename to tests/morpheus/stages/databricks/test_write_to_databricks_deltalake_stage.py index aa9fcafcac..39213f81fb 100644 --- a/tests/morpheus/stages/test_write_to_databricks_deltalake_stage.py +++ b/tests/morpheus/stages/databricks/test_write_to_databricks_deltalake_stage.py @@ -12,12 +12,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -try: - import databricks.connect # pylint: disable=unused-import # noqa -except ImportError: - import pytest - pytest.skip("databricks-connect not installed", allow_module_level=True) - from unittest import mock from unittest.mock import patch