From b3102a097a3ef95430a8bad65b3f171c45dd6cc2 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Mon, 19 May 2008 22:46:14 +0000 Subject: [PATCH] - changed char_length() to use a fake, neutral "generic function" - assert_compile() reports the dialect in use --- test/sql/functions.py | 11 ++++++++++- test/testlib/testing.py | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/test/sql/functions.py b/test/sql/functions.py index 82814ef1b9..6754d6d428 100644 --- a/test/sql/functions.py +++ b/test/sql/functions.py @@ -7,6 +7,7 @@ from sqlalchemy.sql.compiler import BIND_TEMPLATES from sqlalchemy.engine import default from sqlalchemy import types as sqltypes from testlib import * +from sqlalchemy.sql.functions import GenericFunction from sqlalchemy.databases import * # every dialect in databases.__all__ is expected to pass these tests. @@ -31,7 +32,15 @@ class CompileTest(TestBase, AssertsCompiledSQL): self.assert_compile(func.nosuchfunction(), "nosuchfunction", dialect=dialect) else: self.assert_compile(func.nosuchfunction(), "nosuchfunction()", dialect=dialect) - self.assert_compile(func.char_length('foo'), "char_length(%s)" % bindtemplate % {'name':'param_1', 'position':1}, dialect=dialect) + + # test generic function compile + class fake_func(GenericFunction): + __return_type__ = sqltypes.Integer + + def __init__(self, arg, **kwargs): + GenericFunction.__init__(self, args=[arg], **kwargs) + + self.assert_compile(fake_func('foo'), "fake_func(%s)" % bindtemplate % {'name':'param_1', 'position':1}, dialect=dialect) def test_underscores(self): self.assert_compile(func.if_(), "if()") diff --git a/test/testlib/testing.py b/test/testlib/testing.py index 28cc0388c9..eda83a55df 100644 --- a/test/testlib/testing.py +++ b/test/testlib/testing.py @@ -695,7 +695,7 @@ class AssertsCompiledSQL(object): cc = re.sub(r'\n', '', str(c)) - self.assertEquals(cc, result) + self.assertEquals(cc, result, "%r != %r on dialect %r" % (cc, result, dialect)) if checkparams is not None: self.assertEquals(c.construct_params(params), checkparams) -- 2.47.3