django_any/models.py
def any_url_field(field, **kwargs):
    """
    Return random value for URLField
    >>> result = any_field(models.URLField())
    >>> from django.core.validators import URLValidator
    >>> re.match(URLValidator.regex, result) is not None
    True
    """
    url = kwargs.get('url')

    if not url:
        verified = [validator for validator in field.validators \
                    if isinstance(validator, validators.URLValidator) and \
                    validator.verify_exists == True]
        if verified:
            url = choice(['http://news.yandex.ru/society.html',
                          'http://video.google.com/?hl=en&tab=wv',
                          'http://www.microsoft.com/en/us/default.aspx',
                          'http://habrahabr.ru/company/opera/',
                          'http://www.apple.com/support/hardware/',
                          'http://ya.ru',
                          'http://google.com',
                          'http://fr.wikipedia.org/wiki/France'])
        else:
            url = "http://%s.%s/%s" % (
                xunit.any_string(max_length=10),
                xunit.any_string(min_length=2, max_length=3),
                xunit.any_string(max_length=20))

    return url
def any_url_field(field, **kwargs):
    """
    Return random value for URLField
    >>> result = any_field(models.URLField())
    >>> from django.core.validators import URLValidator
    >>> re.match(URLValidator.regex, result) is not None
    True
    """
    url = kwargs.get('url')

    if not url:
        verified = [validator for validator in field.validators \
                    if isinstance(validator, validators.URLValidator) and \
                    validator.verify_exists == True]
        if verified:
            url = choice(['http://news.yandex.ru/society.html',
                          'http://video.google.com/?hl=en&tab=wv',
                          'http://www.microsoft.com/en/us/default.aspx',
                          'http://habrahabr.ru/company/opera/',
                          'http://www.apple.com/support/hardware/',
                          'http://ya.ru',
                          'http://google.com',
                          'http://fr.wikipedia.org/wiki/France'])
        else:
            url = "http://%s.%s/%s" % (
                xunit.any_string(max_length=10),
                xunit.any_string(min_length=2, max_length=3),
                xunit.any_string(max_length=20))

    return url
Return random value for URLField
    >>> result = any_field(models.URLField())
    >>> from django.core.validators import URLValidator
    >>> re.match(URLValidator.regex, result) is not None
    True