class TestHTTPField(unittest.TestCase): def setUp(self): self.field = HTTPField() def test_validate_wrong_urls(self): wrong_urls = [ 'aaaaaaaa', 'some.url.domain', '://somestring', 'ftp://some.domain.ru', 'ftps://some.domain.ru' ] for url in wrong_urls: self.assertRaises(ValidationError, self.field.validate, url) def test_validate_regular_url(self): valid_urls = [ 'http://some.domain.ru', 'https://some.domain.ru:8080', 'http://some.domain.ru:8011/path', 'https://some.domain.ru:9001/path¶m1=value1', ] for url in valid_urls: self.assertIsNone(self.field.validate(url))
def setUp(self): self.field = HTTPField()