Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions tests/unit/functions/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)


Expand Down Expand Up @@ -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, output_type=int)
assert not has_conflict_output_type(signature, output_type=float)