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