def test_is_shorter_or_equal_throws_error_on_longer_length(value: str, max_length: int):
    """
    Tests that the `is_shorter_or_equal()` method throws an ArgumentError
    when it is supplied with a longer length.
    """
    # Arrange
    validator = StringValidator(value, 'value')

    # Assert
    with pytest.raises(ArgumentError):
        # Act
        validator.is_shorter_or_equal(max_length)
def test_is_shorter_or_equal_accepts_equal_length(value: str, max_length: int):
    """
    Tests that the `is_shorter_or_equal()` method does not throw an ArgumentError
    when it is supplied with a equal length.
    """
    # Arrange
    validator = StringValidator(value, 'value')

    # Act
    try:
        validator.is_shorter_or_equal(max_length)
    # Assert
    except ArgumentError:
        pytest.fail(f'`{value}` should be shorter or equal to `{max_length}`, but an error occurred.')
def test_is_shorter_or_equal_returns_validator_self():
    """
    Tests if the `is_shorter_or_equal()` validator method returns itself after the validation is performed,
	so that additional validations can be performed.
    """
    # Arrange
    value = 'test'
    max_length = 10
    validator = StringValidator(value, 'value')

    # Act
    validator_returned = validator.is_shorter_or_equal(max_length)

    # Assert
    assert validator_returned is validator