diff --git a/tests/ast/test_ast_driver.py b/tests/ast/test_ast_driver.py index 250e972cde..96f8374fea 100644 --- a/tests/ast/test_ast_driver.py +++ b/tests/ast/test_ast_driver.py @@ -95,11 +95,15 @@ def load_test_cases(): Returns: a list of test cases. """ test_files = DATA_DIR.glob("*.test") - if sys.version_info[0] == 3 and sys.version_info[1] < 9: + major_version, minor_version = sys.version_info[0], sys.version_info[1] + if major_version == 3 and minor_version < 9: # Remove the `to_snowpark_pandas` test since Snowpark pandas is only supported in Python 3.9+. test_files = filter( lambda file: "to_snowpark_pandas" not in file.name, test_files ) + if major_version == 3 and minor_version == 12: + # Skip df_copy when run in Python 3.12 due to differences in reported source positions. + test_files = filter(lambda file: "df_copy" not in file.name, test_files) return [parse_file(file) for file in test_files] diff --git a/tests/integ/test_df_to_snowpark_pandas.py b/tests/integ/test_df_to_snowpark_pandas.py index 74aac13d8c..6c181120f6 100644 --- a/tests/integ/test_df_to_snowpark_pandas.py +++ b/tests/integ/test_df_to_snowpark_pandas.py @@ -40,6 +40,13 @@ def tmp_table_basic(session): @pytest.mark.parametrize("enforce_ordering", [True, False]) def test_to_snowpark_pandas_no_modin(session, tmp_table_basic, enforce_ordering): snowpark_df = session.table(tmp_table_basic) + # If pandas isn't installed, then an error is raised immediately. + try: + import pandas # noqa: F401 + except ModuleNotFoundError: + with pytest.raises(ModuleNotFoundError, match="No module named 'pandas'"): + snowpark_df.to_snowpark_pandas(enforce_ordering=enforce_ordering) + return # Check if modin is installed (if so, we're running in Snowpark pandas; if not, we're just in Snowpark Python) try: import modin # noqa: F401