Xunit reference

The python basic types generators

django_any.xunit.any_boolean()

Returns True or False

>>> result = any_boolean()
>>> type(result)
<type 'bool'>
django_any.xunit.any_date(from_date=datetime.date(1990, 1, 1), to_date=datetime.date(2012, 1, 22))

Return random date from the [from_date, to_date] interval

>>> result = any_date(from_date=date(1990,1,1), to_date=date(1990,1,3))
>>> type(result)
<type 'datetime.date'>
>>> result >= date(1990,1,1) and result <= date(1990,1,3)
True
django_any.xunit.any_datetime(from_date=datetime.datetime(1990, 1, 1, 0, 0), to_date=datetime.datetime(2012, 1, 22, 12, 44, 0, 971574))

Return random datetime from the [from_date, to_date] interval

>>> result = any_datetime(from_date=datetime(1990,1,1), to_date=datetime(1990,1,3))
>>> type(result)
<type 'datetime.datetime'>
>>> result >= datetime(1990,1,1) and result <= datetime(1990,1,3)
True
django_any.xunit.any_decimal(min_value=Decimal('0'), max_value=Decimal('99.99'), decimal_places=2)

Return random decimal from the [min_value, max_value] interval

>>> result = any_decimal(min_value=0.999, max_value=3, decimal_places=3)
>>> type(result)
<class 'decimal.Decimal'>
>>> result >= Decimal('0.999') and result <= Decimal(3)
True
django_any.xunit.any_float(min_value=0, max_value=100, precision=2)

Returns random float

>>> result = any_float(min_value=0, max_value=100, precision=2)
>>> type(result)
<type 'float'>
>>> result >=0 and result <= 100
True
django_any.xunit.any_int(min_value=0, max_value=100, **kwargs)

Return random integer from the selected range

>>> result = any_int(min_value=0, max_value=100)
>>> type(result)
<type 'int'>
>>> result in range(0,101)
True
django_any.xunit.any_letter(letters='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ', **kwargs)

Return random letter

>>> result = any_letter(letters = ascii_letters)
>>> type(result)
<type 'str'>
>>> len(result)
1
>>> result in ascii_letters
True
django_any.xunit.any_string(letters='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ', min_length=3, max_length=100)

Return string with random content

>>> result = any_string(letters = ascii_letters, min_length=3, max_length=100)
>>> type(result)
<type 'str'>
>>> len(result) in range(3,101)
True
>>> any([c in ascii_letters for c in result])
True
django_any.xunit.weighted_choice(choices)

Supposes that choices is sequence of two elements items, where first one is the probability and second is the result object or callable

>>> result = weighted_choice([(20,'x'), (100, 'y')])
>>> result in ['x', 'y']
True

Previous topic

Debugging

Next topic

Changelog

This Page