Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

32 lines (21 sloc) 0.737 kb
"""Provide tools for generating objects for testing purposes."""
from random import randint
import random
import string
from bookie.models import Tag
def random_int(max=1000):
"""Generate a random integer value
:param max: Maximum value to hit.
return randint(0, max)
def random_string(length=None):
"""Generates a random string from urandom.
:param length: Specify the number of chars in the generated string.
chars = string.ascii_uppercase + string.digits
str_length = length if length is not None else random_int()
return ''.join(random.choice(chars) for x in range(str_length))
def make_tag(name=None):
if not name:
name = random_string(255)
return Tag(name)
Jump to Line
Something went wrong with that request. Please try again.