From 6230dfbd392cc9eb5720777ea56fa97d403b69b5 Mon Sep 17 00:00:00 2001 From: tdhooghe Date: Tue, 22 Oct 2024 11:52:02 +0200 Subject: [PATCH] try except block for snowpark imports Signed-off-by: tdhooghe --- .../tests/snowflake/test_snowpark_dataset.py | 27 +++++++++++-------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/kedro-datasets/tests/snowflake/test_snowpark_dataset.py b/kedro-datasets/tests/snowflake/test_snowpark_dataset.py index 3758b6efc..f9cc976a2 100644 --- a/kedro-datasets/tests/snowflake/test_snowpark_dataset.py +++ b/kedro-datasets/tests/snowflake/test_snowpark_dataset.py @@ -3,18 +3,23 @@ import pandas as pd import pytest -from snowflake.snowpark import DataFrame -from snowflake.snowpark.session import Session -from snowflake.snowpark.types import ( - DateType, - FloatType, - IntegerType, - StringType, - StructField, - StructType, - TimestampType, -) +# needed for pytest to skip tests for python versions >= 3.12 +try: + from snowflake.snowpark import DataFrame, Session + from snowflake.snowpark.types import ( + DateType, + FloatType, + IntegerType, + StringType, + StructField, + StructType, + TimestampType, + ) + + SNOWPARK_AVAILABLE = True +except ImportError: + SNOWPARK_AVAILABLE = False from kedro_datasets.snowflake.snowpark_dataset import SnowparkTableDataset # Example dummy configuration for testing