Skip to content

Commit b692713

Browse files
authored
test: Add unit test for has_conflict_output_type (#2003)
* test: Add unit test for has_conflict_output_type * fix
1 parent 8159f8f commit b692713

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

tests/unit/functions/test_utils.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,13 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
import inspect
1516
from unittest.mock import patch
1617

1718
from bigframes.functions._utils import (
1819
_package_existed,
1920
get_updated_package_requirements,
21+
has_conflict_output_type,
2022
)
2123

2224

@@ -147,3 +149,27 @@ def test_package_existed_helper():
147149
assert not _package_existed(reqs, "xgboost")
148150
# Empty list
149151
assert not _package_existed([], "pandas")
152+
153+
154+
def test_has_conflict_output_type_no_conflict():
155+
"""Tests has_conflict_output_type with type annotation."""
156+
# Helper functions with type annotation for has_conflict_output_type.
157+
def _func_with_return_type(x: int) -> int:
158+
return x
159+
160+
signature = inspect.signature(_func_with_return_type)
161+
162+
assert has_conflict_output_type(signature, output_type=float)
163+
assert not has_conflict_output_type(signature, output_type=int)
164+
165+
166+
def test_has_conflict_output_type_no_annotation():
167+
"""Tests has_conflict_output_type without type annotation."""
168+
# Helper functions without type annotation for has_conflict_output_type.
169+
def _func_without_return_type(x):
170+
return x
171+
172+
signature = inspect.signature(_func_without_return_type)
173+
174+
assert not has_conflict_output_type(signature, output_type=int)
175+
assert not has_conflict_output_type(signature, output_type=float)

0 commit comments

Comments
 (0)