Skip to content

Commit

Permalink
rename test to columns_conditions, add note on overloading 'in' keyword
Browse files Browse the repository at this point in the history
overloading 'in' is not possible as it always casts to bool
  • Loading branch information
icyveins7 committed Mar 19, 2024
1 parent 3947cfc commit f249985
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
2 changes: 2 additions & 0 deletions sew/condition.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

7 changes: 7 additions & 0 deletions tests/columns.py → tests/columns_conditions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)"
)


0 comments on commit f249985

Please sign in to comment.