def float_field_data(field, **kwargs): """ Return random value for FloatField >>> result = any_form_field(forms.FloatField(max_value=200, min_value=100)) >>> type(result) <type 'str'> >>> float(result) >=100, float(result) <=200 (True, True) """ min_value = 0 max_value = 100 from django.core.validators import MaxValueValidator, MinValueValidator for elem in field.validators: if isinstance(elem, MinValueValidator): min_value = elem.limit_value if isinstance(elem, MaxValueValidator): max_value = elem.limit_value min_value = kwargs.get('min_value', min_value) max_value = kwargs.get('max_value', max_value) precision = kwargs.get('precision', 3) return str( xunit.any_float(min_value=min_value, max_value=max_value, precision=precision))
def any_float_field(field, **kwargs): """ Return random value for FloatField >>> result = any_field(models.FloatField()) >>> type(result) <type 'float'> """ min_value = kwargs.get('min_value', 1) max_value = kwargs.get('max_value', 100) precision = kwargs.get('precision', 3) return xunit.any_float(min_value=min_value, max_value=max_value, precision=precision)
def float_field_data(field, **kwargs): """ Return random value for FloatField >>> result = any_form_field(forms.FloatField(max_value=200, min_value=100)) >>> type(result) <type 'str'> >>> float(result) >=100, float(result) <=200 (True, True) """ min_value = 0 max_value = 100 from django.core.validators import MinValueValidator, MaxValueValidator for elem in field.validators: if isinstance(elem, MinValueValidator): min_value = elem.limit_value if isinstance(elem, MaxValueValidator): max_value = elem.limit_value min_value = kwargs.get('min_value', min_value) max_value = kwargs.get('max_value', max_value) precision = kwargs.get('precision', 3) return str(xunit.any_float(min_value=min_value, max_value=max_value, precision=precision))