diff --git a/src/expycted/internals/base.py b/src/expycted/internals/base.py index f09c11f..1be7e8f 100644 --- a/src/expycted/internals/base.py +++ b/src/expycted/internals/base.py @@ -51,6 +51,8 @@ def _execute_internal_assertion(self, method: str, *args, **kwargs): @property def to(self): + self.negate = False + return self @property @@ -59,7 +61,8 @@ def and_to(self): @property def to_not(self): - self.negate = not self.negate + self.negate = True + return self @property diff --git a/test/other_tests.py b/test/other_tests.py index 564aab0..099fb30 100644 --- a/test/other_tests.py +++ b/test/other_tests.py @@ -35,3 +35,11 @@ def test_method_chaining(): assert expect_object.and_to_not is expect_object expect([1, 2, 3]).to_not.contain(7).and_to.contain(3) + + +def test_negation_chaining(): + expect_object = expect.value(1) + + assert expect_object.to.negate is False + assert expect_object.to_not.negate is True + assert expect_object.to_not.to.negate is False