def test_is_equal_using_eq_should_throw_on_unequal_objects(): """ Tests that the `is_equal_to_using_eq()` method throws an ArgumentError when the object is not equal to the supplied object using the `__eq__()` method. """ # Arrange actual = TypeEqualityExample(10) expected = TypeEqualityExample(11) validator = ObjectValidator(actual, 'actual') # Assert with pytest.raises(ArgumentError): # Act validator.is_equal_to_using_eq(expected)
def test_is_equal_using_eq_accepts_equal_objects(): """ Tests that the `is_equal_to_using_eq()` method does not throw an ArgumentError when the object is equal to the supplied object using the `__eq__()` method. """ # Arrange actual = TypeEqualityExample(10) expected = TypeEqualityExample(10) validator = ObjectValidator(actual, 'actual') # Act try: validator.is_equal_to_using_eq(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')
def test_is_equal_using_eq_returns_validator_self(): """ Tests if the `is_equal_to_using_eq()` validator method returns itself after the validation is performed, so that additional validations can be performed. """ # Arrange actual = TypeEqualityExample(10) expected = TypeEqualityExample(10) validator = ObjectValidator(actual, 'actual') # Act validator_returned = validator.is_equal_to_using_eq(expected) # Assert assert validator_returned is validator