File tree Expand file tree Collapse file tree 2 files changed +26
-4
lines changed Expand file tree Collapse file tree 2 files changed +26
-4
lines changed Original file line number Diff line number Diff line change @@ -78,7 +78,9 @@ def submit_pandas_labels(
7878 else :
7979 return
8080
81- if hasattr (cls , method_name ):
81+ # Omit __call__, because its not implemented on the actual instances of
82+ # DataFrame/Series, only as the constructor.
83+ if method_name != "__call__" and hasattr (cls , method_name ):
8284 method = getattr (cls , method_name )
8385 else :
8486 return
Original file line number Diff line number Diff line change @@ -157,11 +157,31 @@ def test_submit_pandas_labels_without_valid_params_for_param_logging(mock_bqclie
157157 mock_bqclient .query .assert_not_called ()
158158
159159
160- def test_submit_pandas_labels_with_internal_method (mock_bqclient ):
160+ @pytest .mark .parametrize (
161+ ("class_name" , "method_name" ),
162+ (
163+ ("Series" , "_repr_latex_" ),
164+ (
165+ "DataFrame" ,
166+ # __call__ should be excluded.
167+ # It's implemented on the pd.DataFrame class but not pd.DataFrame instances.
168+ "__call__" ,
169+ ),
170+ (
171+ "Series" ,
172+ # __call__ should be excluded.
173+ # It's implemented on the pd.Series class but not pd.Series instances.
174+ "__call__" ,
175+ ),
176+ ),
177+ )
178+ def test_submit_pandas_labels_with_internal_method (
179+ mock_bqclient , class_name , method_name
180+ ):
161181 log_adapter .submit_pandas_labels (
162182 mock_bqclient ,
163- "Series" ,
164- "_repr_latex_" ,
183+ class_name ,
184+ method_name ,
165185 task = log_adapter .PANDAS_API_TRACKING_TASK ,
166186 )
167187 mock_bqclient .query .assert_not_called ()
You can’t perform that action at this time.
0 commit comments