def test_is_not_regex_match_throws_error_on_matching_pattern(value: str, pattern: str): """ Tests that the `is_not_regex_match()` method throws an ArgumentPatternError when the value matches the specified pattern. """ # Arrange validator = StringValidator(value, 'value') # Assert with pytest.raises(ArgumentPatternError): # Act validator.is_not_regex_match(pattern)
def test_is_not_regex_match_accepts_not_matching_pattern(value: str, pattern: str): """ Tests that the `is_not_regex_match()` method does not throw an ArgumentPatternError when the value does not match the specified pattern. """ # Arrange validator = StringValidator(value, 'value') # Act try: validator.is_not_regex_match(pattern) # Assert except ArgumentPatternError: pytest.fail(f'`{value}` should match the pattern `{pattern}`, but an error occurred.')
def test_is_not_regex_match_returns_validator_self(): """ Tests if the `is_not_regex_match()` validator method returns itself after the validation is performed, so that additional validations can be performed. """ # Arrange value = '1234' pattern = r'^[a-z]+$' validator = StringValidator(value, 'value') # Act validator_returned = validator.is_not_regex_match(pattern) # Assert assert validator_returned is validator