コード例 #1
0
def test_equals_throws_error_on_notequal_value():
    """
    Tests that the `equals()` method throws an ArgumentError
    when the value is not equal to the specified value.
    """
    # Arrange
    value = 'Hello World!'
    equals = 'Test'
    validator = StringValidator(value, 'value')

    # Assert
    with pytest.raises(ArgumentError):
        # Act
        validator.equals(equals)
コード例 #2
0
def test_equals_accepts_equal_value():
    """
    Tests that the `equals()` method does not throw an ArgumentError
    when the value is equal to the specified value.
    """
    # Arrange
    value = 'Hello World!'
    validator = StringValidator(value, 'value')

    # Act
    try:
        validator.equals(value)
    # Assert
    except ArgumentError:
        pytest.fail()
コード例 #3
0
def test_equals_returns_validator_self():
    """
    Tests if the `equals()` validator method returns itself after the validation is performed,
    so that additional validations can be performed.
    """
    # Arrange
    value = 'test'
    validator = StringValidator(value, 'value')

    # Act
    validator_returned = validator.equals(value)

    # Assert
    assert validator_returned is validator