From 43125e1dadca1d5c096412f886b27057f9b5b7a6 Mon Sep 17 00:00:00 2001 From: Yuyang Wang Date: Mon, 25 Nov 2024 10:41:18 -0800 Subject: [PATCH 1/3] fix test --- tests/unit/test_types.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/unit/test_types.py b/tests/unit/test_types.py index 97160663ac..42834b4467 100644 --- a/tests/unit/test_types.py +++ b/tests/unit/test_types.py @@ -1279,6 +1279,7 @@ def test_snow_type_to_dtype_str(): ), ], ) +@pytest.mark.skipif(not is_pandas_available, reason="Includes testing for pandas types") def test_datatype(tpe, simple_string, json, type_name, json_value): assert tpe.simple_string() == simple_string assert tpe.json_value() == json_value @@ -1382,6 +1383,7 @@ def test_datatype(tpe, simple_string, json, type_name, json_value): (PandasSeriesType, PandasSeriesType(None)), ], ) +@pytest.mark.skipif(not is_pandas_available, reason="Includes testing for pandas types") def test_structtype_from_json(datatype, tpe): json_dict = tpe.json_value() new_obj = datatype.from_json(json_dict) From 41b09f6f7ed4dcf82717d896d4752322f8e79eeb Mon Sep 17 00:00:00 2001 From: Yuyang Wang Date: Mon, 25 Nov 2024 13:38:47 -0800 Subject: [PATCH 2/3] fix test --- tests/unit/test_types.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/unit/test_types.py b/tests/unit/test_types.py index 42834b4467..a9ad0da1fe 100644 --- a/tests/unit/test_types.py +++ b/tests/unit/test_types.py @@ -1050,6 +1050,7 @@ def test_snow_type_to_dtype_str(): snow_type_to_dtype_str(None) +@pytest.mark.skipif(not is_pandas_available, reason="Includes testing for pandas types") @pytest.mark.parametrize( "tpe, simple_string, json, type_name, json_value", [ @@ -1279,7 +1280,6 @@ def test_snow_type_to_dtype_str(): ), ], ) -@pytest.mark.skipif(not is_pandas_available, reason="Includes testing for pandas types") def test_datatype(tpe, simple_string, json, type_name, json_value): assert tpe.simple_string() == simple_string assert tpe.json_value() == json_value @@ -1306,6 +1306,7 @@ def test_datatype(tpe, simple_string, json, type_name, json_value): assert tpe.typeName() == type_name +@pytest.mark.skipif(not is_pandas_available, reason="Includes testing for pandas types") @pytest.mark.parametrize( "datatype, tpe", [ @@ -1383,7 +1384,6 @@ def test_datatype(tpe, simple_string, json, type_name, json_value): (PandasSeriesType, PandasSeriesType(None)), ], ) -@pytest.mark.skipif(not is_pandas_available, reason="Includes testing for pandas types") def test_structtype_from_json(datatype, tpe): json_dict = tpe.json_value() new_obj = datatype.from_json(json_dict) From d219a320c1c930596f3678c63c75306fa70df7db Mon Sep 17 00:00:00 2001 From: Yuyang Wang Date: Mon, 25 Nov 2024 14:52:54 -0800 Subject: [PATCH 3/3] fix test --- tests/unit/test_types.py | 38 ++++++++++++++++++++++++++++---------- 1 file changed, 28 insertions(+), 10 deletions(-) diff --git a/tests/unit/test_types.py b/tests/unit/test_types.py index a9ad0da1fe..d5ffc9757f 100644 --- a/tests/unit/test_types.py +++ b/tests/unit/test_types.py @@ -1050,7 +1050,6 @@ def test_snow_type_to_dtype_str(): snow_type_to_dtype_str(None) -@pytest.mark.skipif(not is_pandas_available, reason="Includes testing for pandas types") @pytest.mark.parametrize( "tpe, simple_string, json, type_name, json_value", [ @@ -1238,7 +1237,9 @@ def test_snow_type_to_dtype_str(): {"name": "col2", "type": "float"}, ], }, - ), + ) + if is_pandas_available + else (None, None, None, None, None), ( PandasDataFrameType( [ArrayType(ArrayType(IntegerType())), IntegerType(), FloatType()] @@ -1263,24 +1264,32 @@ def test_snow_type_to_dtype_str(): {"name": "", "type": "float"}, ], }, - ), + ) + if is_pandas_available + else (None, None, None, None, None), ( PandasSeriesType(IntegerType()), "pandas_series", '{"element_type":"integer","type":"pandas_series"}', "pandas_series", {"type": "pandas_series", "element_type": "integer"}, - ), + ) + if is_pandas_available + else (None, None, None, None, None), ( PandasSeriesType(None), "pandas_series<>", '{"element_type":null,"type":"pandas_series"}', "pandas_series", {"type": "pandas_series", "element_type": None}, - ), + ) + if is_pandas_available + else (None, None, None, None, None), ], ) def test_datatype(tpe, simple_string, json, type_name, json_value): + if tpe is None: + pytest.skip("skip because pandas is not available") assert tpe.simple_string() == simple_string assert tpe.json_value() == json_value assert tpe.json() == json @@ -1306,7 +1315,6 @@ def test_datatype(tpe, simple_string, json, type_name, json_value): assert tpe.typeName() == type_name -@pytest.mark.skipif(not is_pandas_available, reason="Includes testing for pandas types") @pytest.mark.parametrize( "datatype, tpe", [ @@ -1373,18 +1381,28 @@ def test_datatype(tpe, simple_string, json, type_name, json_value): PandasDataFrameType( [StringType(), IntegerType(), FloatType()], ["id", "col1", "col2"] ), - ), + ) + if is_pandas_available + else (None, None), ( PandasDataFrameType, PandasDataFrameType( [ArrayType(ArrayType(IntegerType())), IntegerType(), FloatType()] ), - ), - (PandasSeriesType, PandasSeriesType(IntegerType())), - (PandasSeriesType, PandasSeriesType(None)), + ) + if is_pandas_available + else (None, None), + (PandasSeriesType, PandasSeriesType(IntegerType())) + if is_pandas_available + else (None, None), + (PandasSeriesType, PandasSeriesType(None)) + if is_pandas_available + else (None, None), ], ) def test_structtype_from_json(datatype, tpe): + if datatype is None: + pytest.skip("skip because pandas is not available") json_dict = tpe.json_value() new_obj = datatype.from_json(json_dict) assert new_obj == tpe