'Generates a random password.
@param length: Integer. Length of a password
@param special_chars: Boolean. Whether to use special characters !@#$%^&*()_+
@param digits: Boolean. Whether to use digits
@param upper_case: Boolean. Whether to use upper letters
@param lower_case: Boolean. Whether to use lower letters
@return: String. Random password'

@classmethod
def password(cls, length=10, special_chars=True, digits=True, upper_case=True, lower_case=True):

    choices = u''
    required_tokens = []
    if special_chars:
        required_tokens.append(random.choice(u'!@#$%^&*()_+'))
        choices += u'!@#$%^&*()_+'
    if digits:
        required_tokens.append(random.choice(string.digits))
        choices += string.digits
    if upper_case:
        required_tokens.append(random.choice(string.ascii_uppercase))
        choices += string.ascii_uppercase
    if lower_case:
        required_tokens.append(random.choice(string.ascii_lowercase))
        choices += string.ascii_lowercase
    assert (len(required_tokens) <= length), u'Required    length    is    shorter    than    required    characters'
    chars = [random.choice(choices) for x in range(length)]
    random_indexes = set()
    while (len(random_indexes) < len(required_tokens)):
        random_indexes.add(random.randint(0, (len(chars) - 1)))
    for (i, index) in enumerate(random_indexes):
        chars[index] = required_tokens[i]
    return u''.join(chars)
