Skip to content

Commit

Permalink
adding support for labels
Browse files Browse the repository at this point in the history
  • Loading branch information
miki725 committed Sep 25, 2019
1 parent 84bb6a6 commit da1113d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ nosetests.xml
htmlcov
.cache
.pytest_cache
.mypy_cache

# Translations
*.mo
Expand Down
15 changes: 15 additions & 0 deletions alchemy_mock/comparison.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@
ALCHEMY_BINARY_EXPRESSION_TYPE = type(column("") == "")
ALCHEMY_BOOLEAN_CLAUSE_LIST = type(or_(column("") == "", column("").is_(None)))
ALCHEMY_FUNC_TYPE = type(func.dummy(column("")))
ALCHEMY_LABEL_TYPE = type(column("").label(""))
ALCHEMY_TYPES = (
ALCHEMY_UNARY_EXPRESSION_TYPE,
ALCHEMY_BINARY_EXPRESSION_TYPE,
ALCHEMY_BOOLEAN_CLAUSE_LIST,
ALCHEMY_FUNC_TYPE,
ALCHEMY_LABEL_TYPE,
)


Expand Down Expand Up @@ -66,6 +68,11 @@ class ExpressionMatcher(PrettyExpression):
For example::
>>> c = column('column')
>>> c2 = column('column2')
>>> l1 = c.label('foo')
>>> l2 = c.label('foo')
>>> l3 = c.label('bar')
>>> l4 = c2.label('foo')
>>> e1 = c.in_(['foo', 'bar'])
>>> e2 = c.in_(['foo', 'bar'])
>>> e3 = c.in_(['cat', 'dog'])
Expand All @@ -90,6 +97,14 @@ class ExpressionMatcher(PrettyExpression):
False
>>> ExpressionMatcher(e1) == ExpressionMatcher(e2)
True
>>> ExpressionMatcher(c) == l1
False
>>> ExpressionMatcher(l1) == l2
True
>>> ExpressionMatcher(l1) == l3
True
>>> ExpressionMatcher(l1) == l4
False
It also works with nested structures::
Expand Down

0 comments on commit da1113d

Please sign in to comment.