Exemplo n.º 1
0
def test_bad_short_url_regex():
    for item in BAD_SHORT_URLS:
        assert SHORT_URL_REGEX.search(item) is None
Exemplo n.º 2
0
def replace_urls(text, replace_with='<url>'):
    """Replace all URLs in ``text`` str with ``replace_with`` str."""
    return URL_REGEX.sub(replace_with, SHORT_URL_REGEX.sub(replace_with, text))
Exemplo n.º 3
0
def test_good_short_url_regex():
    for item in GOOD_SHORT_URLS:
        assert item == SHORT_URL_REGEX.search(item).group()
Exemplo n.º 4
0
def replace_urls(text, replace_with='*URL*'):
    """Replace all URLs in ``text`` str with ``replace_with`` str."""
    return URL_REGEX.sub(replace_with, SHORT_URL_REGEX.sub(replace_with, text))
Exemplo n.º 5
0
 def test_bad_short_url_regex(self):
     for item in BAD_SHORT_URLS:
         self.assertIsNone(SHORT_URL_REGEX.search(item))
Exemplo n.º 6
0
 def test_good_short_url_regex(self):
     for item in GOOD_SHORT_URLS:
         self.assertEqual(item, SHORT_URL_REGEX.search(item).group())
Exemplo n.º 7
0
 def test_bad_short_url_regex(self):
     for item in BAD_SHORT_URLS:
         self.assertIsNone(SHORT_URL_REGEX.search(item))
Exemplo n.º 8
0
 def test_good_short_url_regex(self):
     for item in GOOD_SHORT_URLS:
         self.assertEqual(item, SHORT_URL_REGEX.search(item).group())