def test_is_equal_throws_error_on_non_identical_object(): """ Tests that the `is_equal_to()` method throws an ArgumentError when the object is not identical to the supplied object. """ # Arrange actual = TypeExample() expected = TypeExample2() validator = ObjectValidator(actual, 'actual') # Assert with pytest.raises(ArgumentError): # Act validator.is_equal_to(expected)
def test_is_equal_to_accepts_identical_object(): """ Tests that the `is_equal_to()` method does not throw an ArgumentError when the object is identical to the supplied object. """ # Arrange actual = TypeExample() expected = TypeExample() validator = ObjectValidator(actual, 'actual') # Act try: validator.is_equal_to(expected) # Assert except ArgumentError: pytest.fail(f'`{actual.__class__.__name__}` should be equal to `{expected.__class__.__name__}`, but an error occurred')
def test_is_equal_returns_validator_self(): """ Tests if the `is_equal_to()` validator method returns itself after the validation is performed, so that additional validations can be performed. """ actual = TypeExample() expected = TypeExample() validator = ObjectValidator(actual, 'actual') # Act validator_returned = validator.is_equal_to(expected) # Assert assert validator_returned is validator