def test_is_null_or_empty_throws_error_on_invalid_value(value: str): """ Tests that the `is_null_or_empty()` method throws an ArgumentError when it is supplied with an invalid value. """ # Arrange validator = StringValidator(value, 'value') # Assert with pytest.raises(ArgumentError): # Act validator.is_null_or_empty()
def test_is_null_or_empty_throws_error_on_whitespace_value(): """ Tests that the `is_null_or_empty()` method throws an ArgumentError when it is supplied with a whitespace value. """ # Arrange value = WHITESPACE_STRING validator = StringValidator(value, 'value') # Assert with pytest.raises(ArgumentError): # Act validator.is_null_or_empty()
def test_is_null_or_empty_accepts_empty_value(): """ Tests that the `is_null_or_empty()` method does not throw an ArgumentError when it is supplied with a empty value. """ # Arrange value = EMPTY_STRING validator = StringValidator(value, 'value') # Act try: validator.is_null_or_empty() # Assert except ArgumentError: pytest.fail(f'`{value}` should have been None (Null) or empty, but an error occurred instead.')
def test_is_null_or_empty_returns_validator_self(): """ Tests if the `is_null_or_empty()` validator method returns itself after the validation is performed, so that additional validations can be performed. """ # Arrange value = EMPTY_STRING validator = StringValidator(value, 'value') # Act validator_returned = validator.is_null_or_empty() # Assert assert validator_returned is validator