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