def test_does_not_contain_throw_error_on_invalid_value(value: str, contains: str): """ Tests that the `does_not_contain()` method throws an ArgumentError when the value contains specified value. """ # Arrange validator = StringValidator(value, 'value') # Assert with pytest.raises(ArgumentError): # Act validator.does_not_contain(contains)
def test_does_not_contain_accepts_valid_value(value: str, contains: str): """ Tests that the `does_not_contain()` method does not throw an ArgumentError when the value does not contain specified value. """ # Arrange validator = StringValidator(value, 'value') # Act try: validator.does_not_contain(contains) # Assert except ArgumentError: pytest.fail(f'`{value}` should not contain `{contains}`, but an error occurred.')
def test_does_not_contain_returns_validator_self(): """ Tests if the `does_not_contain()` validator method returns itself after the validation is performed, so that additional validations can be performed. """ # Arrange value = 'Hello World' contains = 'test' validator = StringValidator(value, 'value') # Act validator_returned = validator.does_not_contain(contains) # Assert assert validator_returned is validator