From b22edf1d8a16467a8d5625f4ddf7dca9403bdfe0 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Thu, 11 Dec 2008 23:28:01 +0000 Subject: - turn __visit_name__ into an explicit member. [ticket:1244] --- test/sql/generative.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'test/sql') diff --git a/test/sql/generative.py b/test/sql/generative.py index 4edf334f6..daa2432da 100644 --- a/test/sql/generative.py +++ b/test/sql/generative.py @@ -18,6 +18,8 @@ class TraversalTest(TestBase, AssertsExecutionResults): # establish two ficticious ClauseElements. # define deep equality semantics as well as deep identity semantics. class A(ClauseElement): + __visit_name__ = 'a' + def __init__(self, expr): self.expr = expr @@ -34,6 +36,8 @@ class TraversalTest(TestBase, AssertsExecutionResults): return "A(%s)" % repr(self.expr) class B(ClauseElement): + __visit_name__ = 'b' + def __init__(self, *items): self.items = items @@ -137,6 +141,19 @@ class TraversalTest(TestBase, AssertsExecutionResults): assert struct != s3 assert struct3 == s3 + def test_visit_name(self): + # override fns in testlib/schema.py + from sqlalchemy import Column + + class CustomObj(Column): + pass + + assert CustomObj.__visit_name__ == Column.__visit_name__ == 'column' + + foo, bar = CustomObj('foo', String), CustomObj('bar', String) + bin = foo == bar + s = set(ClauseVisitor().iterate(bin)) + assert set(ClauseVisitor().iterate(bin)) == set([foo, bar, bin]) class ClauseTest(TestBase, AssertsCompiledSQL): """test copy-in-place behavior of various ClauseElements.""" -- cgit v1.2.1