From 09080baad1a9f910a5a406dfad9241104ccbc6d8 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Sat, 4 Jun 2011 20:52:30 -0400 Subject: - Adjusted the __contains__() method of a RowProxy result row such that no exception throw is generated internally; NoSuchColumnError() also will generate its message regardless of whether or not the column construct can be coerced to a string. [ticket:2178]. Also in 0.6.8. --- test/sql/test_query.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'test/sql') diff --git a/test/sql/test_query.py b/test/sql/test_query.py index c295cd282..359123f57 100644 --- a/test/sql/test_query.py +++ b/test/sql/test_query.py @@ -341,6 +341,25 @@ class QueryTest(fixtures.TestBase): assert_raises(exc.NoSuchColumnError, lambda: result[0]['fake key']) assert_raises(exc.NoSuchColumnError, lambda: result[0][addresses.c.address_id]) + def test_column_error_printing(self): + row = testing.db.execute(select([1])).first() + class unprintable(object): + def __str__(self): + raise ValueError("nope") + + msg = r"Could not locate column in row for column '%s'" + + for accessor, repl in [ + ("x", "x"), + (Column("q", Integer), "q"), + (Column("q", Integer) + 12, r"q \+ :q_1"), + (unprintable(), "unprintable element.*"), + ]: + assert_raises_message( + exc.NoSuchColumnError, + msg % repl, + lambda: row[accessor] + ) @testing.requires.boolean_col_expressions -- cgit v1.2.1