django_test_tools.re package

Submodules

django_test_tools.re.regexp module

class django_test_tools.re.regexp.CommonRegExp(**kwargs)[source]

Bases: object

This class is a utility for commonly used regular expressions.

str_data = '10:45'
common_regexp = CommonRegExp()
regular_expression, key = common_regexp.match_regexp(str_data)
self.assertEqual(regular_expression, '([0-1][0-9]|2[0-4]):([0-5][0-9])')
self.assertEqual(key, 'time_military')

if the strict keyword is used the class will add ^ at the begining and a $ at the end if the already are not present.

add_regular_expression(name, pattern, **kwargs)[source]
match_regexp(value)[source]

Module contents