|
1 | | -# Copyright 2025 Google LLC |
| 1 | +# Copyright 2024 Google LLC |
2 | 2 | # |
3 | 3 | # Licensed under the Apache License, Version 2.0 (the "License"); |
4 | 4 | # you may not use this file except in compliance with the License. |
|
21 | 21 |
|
22 | 22 |
|
23 | 23 | def test_unsupported_type_error_init_with_dict(): |
24 | | - err = function_typing.UnsupportedTypeError( |
25 | | - decimal.Decimal, {int: "INT64", float: "FLOAT64"} |
26 | | - ) |
| 24 | + # Arrange |
| 25 | + unsupported_type = decimal.Decimal |
| 26 | + supported_types = {int: "INT64", float: "FLOAT64"} |
| 27 | + |
| 28 | + # Act |
| 29 | + err = function_typing.UnsupportedTypeError(unsupported_type, supported_types) |
| 30 | + |
| 31 | + # Assert |
27 | 32 | assert "Decimal" in str(err) |
28 | 33 | assert "float, int" in str(err) |
29 | 34 |
|
30 | 35 |
|
31 | 36 | def test_unsupported_type_error_init_with_set(): |
32 | | - err = function_typing.UnsupportedTypeError(decimal.Decimal, {int, float}) |
| 37 | + # Arrange |
| 38 | + unsupported_type = decimal.Decimal |
| 39 | + supported_types = {int, float} |
| 40 | + |
| 41 | + # Act |
| 42 | + err = function_typing.UnsupportedTypeError(unsupported_type, supported_types) |
| 43 | + |
| 44 | + # Assert |
33 | 45 | assert "Decimal" in str(err) |
34 | 46 | assert "float, int" in str(err) |
35 | 47 |
|
36 | 48 |
|
37 | 49 | def test_sdk_type_from_python_type_raises_unsupported_type_error(): |
| 50 | + # Arrange |
| 51 | + unsupported_type = datetime.datetime |
| 52 | + |
| 53 | + # Act & Assert |
38 | 54 | with pytest.raises(function_typing.UnsupportedTypeError) as excinfo: |
39 | | - function_typing.sdk_type_from_python_type(datetime.datetime) |
| 55 | + function_typing.sdk_type_from_python_type(unsupported_type) |
40 | 56 | assert "datetime" in str(excinfo.value) |
41 | 57 | assert "bool, bytes, float, int, str" in str(excinfo.value) |
0 commit comments