From 13df74800d28f3cc8a9c1af7f2a45b9d94264c50 Mon Sep 17 00:00:00 2001 From: Dov Benyomin Sohacheski Date: Thu, 8 Dec 2022 08:18:29 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=91=20Hotfix=20reset=20negated=20state?= =?UTF-8?q?=20closes=20#32?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/expycted/internals/base.py | 5 ++++- test/other_tests.py | 8 ++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) 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