diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2011-12-06 12:49:39 -0500 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2011-12-06 12:49:39 -0500 |
| commit | 5c9d53fb02effed81329ca7964f99777f2ab6ec4 (patch) | |
| tree | 3039aba6b3aaebf7a85d1a11457b426f76b7c82f /test/ext | |
| parent | 1dea4c1f87a43e668525b4c917cdc9eb4b56f218 (diff) | |
| download | sqlalchemy-5c9d53fb02effed81329ca7964f99777f2ab6ec4.tar.gz | |
- [bug] the @compiles decorator raises an
informative error message when no "default"
compilation handler is present, rather
than KeyError.
Diffstat (limited to 'test/ext')
| -rw-r--r-- | test/ext/test_compiler.py | 17 |
1 files changed, 17 insertions, 0 deletions
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, + "<class 'test.ext.test_compiler.MyThingy'> " + "construct has no default compilation handler.", + str, MyThingy('x') + ) + def test_annotations(self): """test that annotated clause constructs use the decorated class' compiler. |
