Skip to content

Commit 990f9a6

Browse files
committed
Implementing query.ParameterizedThing.
1 parent ec96084 commit 990f9a6

2 files changed

Lines changed: 23 additions & 8 deletions

File tree

ndb/src/google/cloud/ndb/query.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,17 @@ def __init__(self, *args, **kwargs):
5151

5252

5353
class ParameterizedThing:
54-
def __init__(self, *args, **kwargs):
54+
"""Base class for :class:`Parameter` and :class:`ParameterizedFunction`.
55+
56+
This exists purely for :func:`isinstance` checks.
57+
"""
58+
59+
def __eq__(self, other):
5560
raise NotImplementedError
5661

62+
def __ne__(self, other):
63+
return not self == other
64+
5765

5866
class Parameter(ParameterizedThing):
5967
def __init__(self, *args, **kwargs):

ndb/tests/unit/test_query.py

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,20 @@ def test_Cursor():
2626
assert query.Cursor is NotImplemented
2727

2828

29+
class TestParameterizedThing:
30+
@staticmethod
31+
def test___eq__():
32+
thing = query.ParameterizedThing()
33+
with pytest.raises(NotImplementedError):
34+
thing == None
35+
36+
@staticmethod
37+
def test___ne__():
38+
thing = query.ParameterizedThing()
39+
with pytest.raises(NotImplementedError):
40+
thing != None
41+
42+
2943
class TestConjunctionNode:
3044
@staticmethod
3145
def test_constructor():
@@ -88,13 +102,6 @@ def test_constructor():
88102
query.ParameterizedFunction()
89103

90104

91-
class TestParameterizedThing:
92-
@staticmethod
93-
def test_constructor():
94-
with pytest.raises(NotImplementedError):
95-
query.ParameterizedThing()
96-
97-
98105
class TestParameterNode:
99106
@staticmethod
100107
def test_constructor():

0 commit comments

Comments
 (0)