22import os
33import shutil
44import warnings
5- from unittest .mock import patch
5+ from unittest .mock import MagicMock , patch
66
77import boto3
88import pandas as pd
@@ -662,6 +662,35 @@ def test_to_csv_S3(sample_df, s3_client, s3_bucket, profile_name):
662662 assert sample_df .ww .schema == deserialized_df .ww .schema
663663
664664
665+ @patch ("woodwork.deserializers.utils.getfullargspec" )
666+ def test_to_csv_S3_errors_if_python_version_unsafe (
667+ mock_inspect ,
668+ sample_df ,
669+ s3_client ,
670+ s3_bucket ,
671+ ):
672+ mock_response = MagicMock ()
673+ mock_response .kwonlyargs = []
674+ mock_inspect .return_value = mock_response
675+ sample_df .ww .init (
676+ name = "test_data" ,
677+ index = "id" ,
678+ semantic_tags = {"id" : "tag1" },
679+ logical_types = {"age" : Ordinal (order = [25 , 33 , 57 ])},
680+ )
681+ sample_df .ww .to_disk (
682+ TEST_S3_URL ,
683+ format = "csv" ,
684+ encoding = "utf-8" ,
685+ engine = "python" ,
686+ profile_name = None ,
687+ )
688+ make_public (s3_client , s3_bucket )
689+
690+ with pytest .raises (RuntimeError , match = "Please upgrade your Python version" ):
691+ read_woodwork_table (TEST_S3_URL , profile_name = None )
692+
693+
665694@pytest .mark .parametrize ("profile_name" , [None , False ])
666695def test_serialize_s3_pickle (sample_df , s3_client , s3_bucket , profile_name ):
667696 sample_df .ww .init ()
@@ -673,6 +702,23 @@ def test_serialize_s3_pickle(sample_df, s3_client, s3_bucket, profile_name):
673702 assert sample_df .ww .schema == deserialized_df .ww .schema
674703
675704
705+ @patch ("woodwork.deserializers.deserializer_base.getfullargspec" )
706+ def test_serialize_s3_pickle_errors_if_python_version_unsafe (
707+ mock_inspect ,
708+ sample_df ,
709+ s3_client ,
710+ s3_bucket ,
711+ ):
712+ mock_response = MagicMock ()
713+ mock_response .kwonlyargs = []
714+ mock_inspect .return_value = mock_response
715+ sample_df .ww .init ()
716+ sample_df .ww .to_disk (TEST_S3_URL , format = "pickle" , profile_name = None )
717+ make_public (s3_client , s3_bucket )
718+ with pytest .raises (RuntimeError , match = "Please upgrade your Python version" ):
719+ read_woodwork_table (TEST_S3_URL , profile_name = None )
720+
721+
676722@pytest .mark .parametrize ("profile_name" , [None , False ])
677723def test_serialize_s3_parquet (sample_df , s3_client , s3_bucket , profile_name ):
678724 sample_df .ww .init ()
@@ -688,6 +734,28 @@ def test_serialize_s3_parquet(sample_df, s3_client, s3_bucket, profile_name):
688734 assert sample_df .ww .schema == deserialized_df .ww .schema
689735
690736
737+ @patch ("woodwork.deserializers.parquet_deserializer.getfullargspec" )
738+ def test_serialize_s3_parquet_errors_if_python_version_unsafe (
739+ mock_inspect ,
740+ sample_df ,
741+ s3_client ,
742+ s3_bucket ,
743+ ):
744+ mock_response = MagicMock ()
745+ mock_response .kwonlyargs = []
746+ mock_inspect .return_value = mock_response
747+ sample_df .ww .init ()
748+ sample_df .ww .to_disk (TEST_S3_URL , format = "parquet" , profile_name = None )
749+ make_public (s3_client , s3_bucket )
750+
751+ with pytest .raises (RuntimeError , match = "Please upgrade your Python version" ):
752+ read_woodwork_table (
753+ TEST_S3_URL ,
754+ filename = "data.parquet" ,
755+ profile_name = None ,
756+ )
757+
758+
691759def create_test_credentials (test_path ):
692760 with open (test_path , "w+" ) as f :
693761 f .write ("[test]\n " )
0 commit comments