def test_is_equal_to_throws_error_on_invalid_value(value: number, not_equal_to: number): """ Tests that the `is_equal()` method throws an ArgumentOutOfRangeError when it is supplied with a value that is not equal to the equal value. """ # Arrange validator = NumberValidator(value, "value") # Assert with pytest.raises(ArgumentOutOfRangeError): # Act validator.is_equal_to(not_equal_to)
def test_is_equal_to_accepts_valid_value(value: number, equal_to: number): """ Tests that the `is_equal()` method does not throw an ArgumentOutOfRangeError when it is supplied with a value that is equal to the equal value. """ # Arrange validator = NumberValidator(value, "value") # Act try: validator.is_equal_to(equal_to) # Assert except ArgumentOutOfRangeError: pytest.fail()
def test_is_equal_returns_validator_self(): """ Tests if the `is_equal()` validator method returns itself after the validation is performed, so that additional validations can be performed. """ # Arrange validator = NumberValidator(5, "value") # Act validator_returned = validator.is_equal_to(5) # Assert assert validator_returned is validator