From f2499857952a4be8c7fa3ae5d281b2c5f5e50e5d Mon Sep 17 00:00:00 2001 From: seomac Date: Tue, 19 Mar 2024 12:04:23 +0800 Subject: [PATCH] rename test to columns_conditions, add note on overloading 'in' keyword overloading 'in' is not possible as it always casts to bool --- sew/condition.py | 2 ++ tests/{columns.py => columns_conditions.py} | 7 +++++++ 2 files changed, 9 insertions(+) rename tests/{columns.py => columns_conditions.py} (94%) diff --git a/sew/condition.py b/sew/condition.py index 9d6167c..a4db646 100644 --- a/sew/condition.py +++ b/sew/condition.py @@ -235,3 +235,5 @@ def __le__(self, other: Condition) -> Condition: return Condition(condstr) + ##### NOTE: you cannot overload 'in' keyword, as __contains__ always casts the return to a bool + diff --git a/tests/columns.py b/tests/columns_conditions.py similarity index 94% rename from tests/columns.py rename to tests/columns_conditions.py index 0641560..f06164e 100644 --- a/tests/columns.py +++ b/tests/columns_conditions.py @@ -139,4 +139,11 @@ def test_column_composite_comparisons_noncommutative(self): "col1 < 10 OR (col2 < 10 AND col3 < 10)" ) + # Finally test a 4-way condition + comp = (cond1 | cond2) & (cond3 | "col4 < 100") + self.assertEqual( + str(comp), + "(col1 < 10 OR col2 < 10) AND (col3 < 10 OR col4 < 100)" + ) +