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