class DoesNotMatchRegexOperator(BaseConditionOperator): """An operator that checks if a value does not match against a regex. It's equivalent to:: if not condition_value.match(match_value): ... """ operator_id = 'does-not-match-regex' name = _('Does not match regex') value_field = ConditionValueRegexField() def matches(self, match_value, condition_value, **kwargs): """Return whether the lookup value doesn't match the condition's regex. Args: match_value (unicode): The caller's value to check. condition_value (re.RegexObject): The regex value that the lookup value must not match. **kwargs (dict): Unused extra keyword arguments. Returns: bool: ``True`` if the lookup value doesn't match the regex in the condition. """ return condition_value.match(match_value) is None
def setUp(self): super(ConditionValueRegexFieldTests, self).setUp() self.value_field = ConditionValueRegexField()