MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / test_operators_custom

Method test_operators_custom

test/sql/test_functions.py:125–147  ·  view source on GitHub ↗
(self, op, other, expected, use_custom)

Source from the content-addressed store, hash-verified

123 )
124 @testing.combinations((True,), (False,), argnames="use_custom")
125 def test_operators_custom(self, op, other, expected, use_custom):
126 if use_custom:
127
128 class MyFunc(FunctionElement):
129 inherit_cache = True
130 name = "myfunc"
131 type = Integer()
132
133 @compiles(MyFunc)
134 def visit_myfunc(element, compiler, **kw):
135 return "myfunc(%s)" % compiler.process(element.clauses, **kw)
136
137 expr = op(MyFunc(), other)
138 else:
139 expr = op(func.myfunc(type_=Integer), other)
140
141 self.assert_compile(
142 select(1).where(expr),
143 "SELECT 1 WHERE %s" % (expected,),
144 literal_binds=True,
145 render_postcompile=True,
146 dialect="default_enhanced",
147 )
148
149 def test_use_labels(self):
150 self.assert_compile(

Callers

nothing calls this directly

Calls 5

selectFunction · 0.90
opFunction · 0.85
MyFuncClass · 0.85
assert_compileMethod · 0.80
whereMethod · 0.45

Tested by

no test coverage detected