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