From 5c9d53fb02effed81329ca7964f99777f2ab6ec4 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Tue, 6 Dec 2011 12:49:39 -0500 Subject: - [bug] the @compiles decorator raises an informative error message when no "default" compilation handler is present, rather than KeyError. --- test/ext/test_compiler.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'test/ext') diff --git a/test/ext/test_compiler.py b/test/ext/test_compiler.py index 0f53f2cb0..318a1e76c 100644 --- a/test/ext/test_compiler.py +++ b/test/ext/test_compiler.py @@ -6,7 +6,9 @@ from sqlalchemy.sql.expression import ClauseElement, ColumnClause,\ from sqlalchemy.schema import DDLElement from sqlalchemy.ext.compiler import compiles +from sqlalchemy import exc from sqlalchemy.sql import table, column, visitors +from test.lib.testing import assert_raises_message from test.lib import * class UserDefinedTest(fixtures.TestBase, AssertsCompiledSQL): @@ -105,6 +107,21 @@ class UserDefinedTest(fixtures.TestBase, AssertsCompiledSQL): "FROM mytable WHERE mytable.x > :x_1)" ) + def test_no_default_message(self): + class MyThingy(ColumnClause): + pass + + @compiles(MyThingy, "psotgresql") + def visit_thingy(thingy, compiler, **kw): + return "mythingy" + + assert_raises_message( + exc.CompileError, + " " + "construct has no default compilation handler.", + str, MyThingy('x') + ) + def test_annotations(self): """test that annotated clause constructs use the decorated class' compiler. -- cgit v1.2.1