django_any/forms.py
def decimal_field_data(field, **kwargs):
    """
    Return random value for DecimalField

    >>> result = any_form_field(forms.DecimalField(max_value=100, min_value=11, max_digits=4, decimal_places = 2))
    >>> type(result)
    <type 'str'>
    >>> from decimal import Decimal
    >>> Decimal(result) >= 11, Decimal(result) <= Decimal('99.99')
    (True, True)
    """
    min_value = 0
    max_value = 10
    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
    if (field.max_digits and field.decimal_places):
        from decimal import Decimal
        max_value = min(max_value,
                        Decimal('%s.%s' % ('9'*(field.max_digits-field.decimal_places),
                                           '9'*field.decimal_places)))

    min_value = kwargs.get('min_value') or min_value
    max_value = kwargs.get('max_value') or max_value

    return str(xunit.any_decimal(min_value=min_value,
                             max_value=max_value,
                             decimal_places = field.decimal_places or 2))
def decimal_field_data(field, **kwargs):
    min_value = 0
    max_value = 10
    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
    if (field.max_digits and field.decimal_places):
        from decimal import Decimal
        max_value = min(max_value,
                        Decimal('%s.%s' % ('9'*(field.max_digits-field.decimal_places),
                                           '9'*field.decimal_places)))

    min_value = kwargs.get('min_value') or min_value
    max_value = kwargs.get('max_value') or max_value

    return str(xunit.any_decimal(min_value=min_value,
                             max_value=max_value,
                             decimal_places = field.decimal_places or 2))
def decimal_field_data ( field , * * kwargs ) : min_value = 0 max_value = 10 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 if ( field . max_digits and field . decimal_places ) : from decimal import Decimal max_value = min ( max_value , Decimal ( '%s.%s' % ( '9' * ( field . max_digits - field . decimal_places ) , '9' * field . decimal_places ) ) ) min_value = kwargs . get ( 'min_value' ) or min_value max_value = kwargs . get ( 'max_value' ) or max_value return str ( xunit . any_decimal ( min_value = min_value , max_value = max_value , decimal_places = field . decimal_places or 2 ) )
Return random value for DecimalField

    >>> result = any_form_field(forms.DecimalField(max_value=100, min_value=11, max_digits=4, decimal_places = 2))
    >>> type(result)
    <type 'str'>
    >>> from decimal import Decimal
    >>> Decimal(result) >= 11, Decimal(result) <= Decimal('99.99')
    (True, True)
Return random value for DecimalField