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