Open sshishov opened 2 weeks ago
This is how we are handling it for our tests:
def get_value() -> dec.Decimal:
"""Generates real fake decimal by eliminating `min_value` and `max_value` value which is returned in case of underflow/overflow."""
return next(
item
for item in iter(
lambda: fake['en'].pydecimal(
left_digits=0,
right_digits=4,
min_value=dec.Decimal('0.0001'),
max_value=dec.Decimal(1),
),
None,
)
if item not in {dec.Decimal('0.0001'), dec.Decimal(1)}
)
Distribution of
pydecimal
is very far from optimal which can lead to difficulty of use it in the tests. For instance, it the initial value ismax_value
and the updated value is alsomax_value
then it will "break" the test because the value will not be updated.I can recommend the following approaches (imho):
min
ormax
value (maybe provide special extrakwargs
to support it)Steps to reproduce
Expected behavior
Actual behavior