예제 #1
0
def check_url_error_message(value):
    try:
        types.url(value)
        assert False, u"types.url({0}) should raise an exception".format(value)
    except ValueError as e:
        assert_equals(unicode(e), (u"{0} is not a valid URL. Did you mean: "
                                   u"http://{0}".format(value)))
예제 #2
0
def check_url_error_message(value):
    try:
        types.url(value)
        assert False, u"types.url({0}) should raise an exception".format(value)
    except ValueError as e:
        assert_equal(six.text_type(e),
                      (u"{0} is not a valid URL. Did you mean: http://{0}".format(value)))
예제 #3
0
def check_bad_url_raises(value):
    try:
        types.url(value)
        assert False, "shouldn't get here"
    except ValueError as e:
        assert_equals(six.text_type(e),
                      u"{0} is not a valid URL".format(value))
예제 #4
0
def test_urls():
    urls = [
        'http://www.djangoproject.com/',
        'http://localhost/',
        'http://example.com/',
        'http://www.example.com/',
        'http://www.example.com:8000/test',
        'http://valid-with-hyphens.com/',
        'http://subdomain.example.com/',
        'http://200.8.9.10/',
        'http://200.8.9.10:8000/test',
        'http://valid-----hyphens.com/',
        'http://example.com?something=value',
        'http://example.com/index.php?something=value&another=value2',
        'http://*****:*****@example.com',
        'http://foo:@example.com',
        'http://foo:@2001:db8:85a3::8a2e:370:7334',
        'http://*****:*****@example.com',
    ]

    for value in urls:
        yield assert_equals, types.url(value), value
예제 #5
0
def test_urls():
    urls = [
        'http://www.djangoproject.com/',
        'http://localhost/',
        'http://example.com/',
        'http://www.example.com/',
        'http://www.example.com:8000/test',
        'http://valid-with-hyphens.com/',
        'http://subdomain.example.com/',
        'http://200.8.9.10/',
        'http://200.8.9.10:8000/test',
        'http://valid-----hyphens.com/',
        'http://example.com?something=value',
        'http://example.com/index.php?something=value&another=value2',
        'http://*****:*****@example.com',
        'http://foo:@example.com',
        'http://foo:@2001:db8:85a3::8a2e:370:7334',
        'http://*****:*****@example.com',
        ]

    for value in urls:
        yield assert_equals, types.url(value), value
예제 #6
0
def check_bad_url_raises(value):
    try:
        types.url(value)
        assert False, "shouldn't get here"
    except ValueError as e:
        assert_equal(six.text_type(e), u"{0} is not a valid URL".format(value))