|
12 | 12 | # See the License for the specific language governing permissions and |
13 | 13 | # limitations under the License. |
14 | 14 |
|
| 15 | +import inspect |
15 | 16 | from unittest.mock import patch |
16 | 17 |
|
17 | 18 | from bigframes.functions._utils import ( |
18 | 19 | _package_existed, |
19 | 20 | get_updated_package_requirements, |
| 21 | + has_conflict_output_type, |
20 | 22 | ) |
21 | 23 |
|
22 | 24 |
|
@@ -147,3 +149,27 @@ def test_package_existed_helper(): |
147 | 149 | assert not _package_existed(reqs, "xgboost") |
148 | 150 | # Empty list |
149 | 151 | 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