From d3663af83ae4a98ad4fca13ea28617ecc224c681 Mon Sep 17 00:00:00 2001 From: jialuo Date: Mon, 18 Aug 2025 20:08:03 +0000 Subject: [PATCH 1/2] test: Add unit test for has_conflict_output_type --- tests/unit/functions/test_utils.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/tests/unit/functions/test_utils.py b/tests/unit/functions/test_utils.py index 1556c99357..62c5eedfe1 100644 --- a/tests/unit/functions/test_utils.py +++ b/tests/unit/functions/test_utils.py @@ -12,11 +12,13 @@ # See the License for the specific language governing permissions and # limitations under the License. +import inspect from unittest.mock import patch from bigframes.functions._utils import ( _package_existed, get_updated_package_requirements, + has_conflict_output_type, ) @@ -147,3 +149,27 @@ def test_package_existed_helper(): assert not _package_existed(reqs, "xgboost") # Empty list assert not _package_existed([], "pandas") + + +def test_has_conflict_output_type_no_conflict(): + """Tests has_conflict_output_type with type annotation.""" + # Helper functions with type annotation for has_conflict_output_type. + def _func_with_return_type(x: int) -> int: + return x + + signature = inspect.signature(_func_with_return_type) + + assert has_conflict_output_type(signature, output_type=float) + assert not has_conflict_output_type(signature, output_type=int) + + +def test_has_conflict_output_type_no_annotation(): + """Tests has_conflict_output_type without type annotation.""" + # Helper functions without type annotation for has_conflict_output_type. + def _func_without_return_type(x): + return x + + signature = inspect.signature(_func_without_return_type) + + assert not has_conflict_output_type(signature, int) + assert not has_conflict_output_type(signature, float) From 66a96abf11245ca7991c036d051324b1f9bc7651 Mon Sep 17 00:00:00 2001 From: jialuo Date: Mon, 18 Aug 2025 20:15:59 +0000 Subject: [PATCH 2/2] fix --- tests/unit/functions/test_utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/unit/functions/test_utils.py b/tests/unit/functions/test_utils.py index 62c5eedfe1..8417234fb2 100644 --- a/tests/unit/functions/test_utils.py +++ b/tests/unit/functions/test_utils.py @@ -171,5 +171,5 @@ def _func_without_return_type(x): signature = inspect.signature(_func_without_return_type) - assert not has_conflict_output_type(signature, int) - assert not has_conflict_output_type(signature, float) + assert not has_conflict_output_type(signature, output_type=int) + assert not has_conflict_output_type(signature, output_type=float)