Example #1
0
def test_bad_url_regex():
    for item in BAD_URLS:
        assert URL_REGEX.search(item) is None
Example #2
0
def test_partial_url_regex():
    for item in PARTIAL_URLS:
        assert item != URL_REGEX.search(item)
Example #3
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))
Example #4
0
def test_good_url_regex():
    for item in GOOD_URLS:
        assert item == URL_REGEX.search(item).group()
Example #5
0
 def test_partial_url_regex(self):
     for item in PARTIAL_URLS:
         self.assertNotEqual(item, URL_REGEX.search(item))
Example #6
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))
Example #7
0
 def test_bad_url_regex(self):
     for item in BAD_URLS:
         self.assertIsNone(URL_REGEX.search(item))
Example #8
0
 def test_good_url_regex(self):
     for item in GOOD_URLS:
         self.assertEqual(item, URL_REGEX.search(item).group())
Example #9
0
 def test_partial_url_regex(self):
     for item in PARTIAL_URLS:
         self.assertNotEqual(item, URL_REGEX.search(item))
Example #10
0
 def test_bad_url_regex(self):
     for item in BAD_URLS:
         self.assertIsNone(URL_REGEX.search(item))
Example #11
0
 def test_good_url_regex(self):
     for item in GOOD_URLS:
         self.assertEqual(item, URL_REGEX.search(item).group())