Exemple #1
0
def test_is_not_equal_using_ne_should_throw_on_equal_objects():
    """
    Tests that the `is_not_equal_to_using_ne()` method throws an ArgumentError
    when the object is equal to the supplied object using the `__ne__()` method.
    """
    # Arrange
    actual = TypeEqualityExample(10)
    expected = TypeEqualityExample(10)
    validator = ObjectValidator(actual, 'actual')

    # Assert
    with pytest.raises(ArgumentError):
        # Act
        validator.is_not_equal_to_using_ne(expected)
Exemple #2
0
def test_is_not_equal_using_ne_accepts_unequal_objects():
    """
    Tests that the `is_not_equal_to_using_eq()` method throws an ArgumentError
    when the object is not equal to the supplied object using the `__ne__()` method.
    """
    # Arrange
    actual = TypeEqualityExample(10)
    expected = TypeEqualityExample(11)
    validator = ObjectValidator(actual, 'actual')

    # Act
    try:
        validator.is_not_equal_to_using_ne(expected)
    # Assert
    except ArgumentError:
        pytest.fail(f'`{actual.__class__.__name__}` should be equal to `{expected.__class__.__name__}` when using the `__eq__()` function, but an error occurred')
Exemple #3
0
def test_is_not_equal_using_ne_returns_validator_self():
    """
    Tests if the `is_not_equal_to_using_ne()` validator method returns itself after the validation is performed,
    so that additional validations can be performed.
    """
    # Arrange
    actual = TypeEqualityExample(10)
    expected = TypeEqualityExample(11)
    validator = ObjectValidator(actual, 'actual')

    # Act
    validator_returned = validator.is_not_equal_to_using_ne(expected)

    # Assert
    assert validator_returned is validator