diff options
Diffstat (limited to 'test.py')
| -rw-r--r-- | test.py | 30 |
1 files changed, 30 insertions, 0 deletions
@@ -167,6 +167,36 @@ class TestSlugification(unittest.TestCase): r = slugify(txt) self.assertEqual(r, '1000-reasons-you-are-1') + def test_regex_pattern_keep_underscore(self): + txt = "___This is a test___" + regex_pattern = r'[^-a-z0-9_]+' + r = slugify(txt, regex_pattern=regex_pattern) + self.assertEqual(r, "___this-is-a-test___") + + def test_regex_pattern_keep_underscore_with_underscore_as_separator(self): + """ + The regex_pattern turns the power to the caller. + Hence the caller must ensure that a custom separator doesn't clash + with the regex_pattern. + """ + txt = "___This is a test___" + regex_pattern = r'[^-a-z0-9_]+' + r = slugify(txt, separator='_', regex_pattern=regex_pattern) + self.assertNotEqual(r, "_this_is_a_test_") + + +class TestUtils(unittest.TestCase): + + def test_smart_truncate_no_max_length(self): + txt = '1,000 reasons you are #1' + r = smart_truncate(txt) + self.assertEqual(r, txt) + + def test_smart_truncate_no_seperator(self): + txt = '1,000 reasons you are #1' + r = smart_truncate(txt, max_length=100, separator='_') + self.assertEqual(r, txt) + class TestUtils(unittest.TestCase): |
