Skip to content

Commit 36ce3ba

Browse files
fix: Improve unit test case
The code changes modify the test cases for enum validation with decimal values. The test cases now only include the values -1, 0, and 1. Additionally, a new assertion is added to validate the decimal values as floats. This change improves the validation of enum fields with decimal values.
1 parent 399245b commit 36ce3ba

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

tests/validators/test_enums.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ class ColorEnum(IntEnum):
349349

350350
@pytest.mark.parametrize(
351351
'value',
352-
[-1.0, -1, 0, 1, 1.0],
352+
[-1, 0, 1],
353353
)
354354
def test_enum_int_validation_should_succeed_for_decimal(value: int):
355355
class MyEnum(Enum):
@@ -362,6 +362,7 @@ class MyEnum(Enum):
362362
)
363363
)
364364
assert v.validate_python(Decimal(value)) is MyEnum.VALUE
365+
assert v.validate_python(Decimal(float(value))) is MyEnum.VALUE
365366

366367

367368
def test_enum_int_validation_should_fail_for_incorrect_decimal_value():

0 commit comments

Comments
 (0)