File tree Expand file tree Collapse file tree 2 files changed +14
-1
lines changed Expand file tree Collapse file tree 2 files changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -70,7 +70,7 @@ def _default_render(self, boundcol):
70
70
# also ``_validate_column_name``, where such a mechanism is
71
71
# already implemented).
72
72
if not hasattr (current , bit ):
73
- raise ValueError ("Could not resolve %s from %s" % (bit , name ))
73
+ raise ValueError ("Could not resolve %s from %s" % (bit , boundcol . accessor ))
74
74
75
75
current = getattr (current , bit )
76
76
if callable (current ):
Original file line number Diff line number Diff line change @@ -154,6 +154,18 @@ class CountryTable(tables.ModelTable):
154
154
test_country_table (countries )
155
155
156
156
157
+ def test_invalid_accessor ():
158
+ """Test that a column being backed by a non-existent model property
159
+ is handled correctly.
160
+
161
+ Regression-Test: There used to be a NameError here.
162
+ """
163
+ class CountryTable (tables .ModelTable ):
164
+ name = tables .Column (data = 'something-i-made-up' )
165
+ countries = CountryTable (Country )
166
+ assert_raises (ValueError , countries [0 ].__getitem__ , 'name' )
167
+
168
+
157
169
def test_caches ():
158
170
"""Make sure the caches work for model tables as well (parts are
159
171
reimplemented).
@@ -259,6 +271,7 @@ class Meta:
259
271
assert [row ['example_domain' ] for row in countries ] == \
260
272
[row ['null' ] for row in countries ]
261
273
274
+
262
275
def test_relationships ():
263
276
"""Test relationship spanning."""
264
277
You can’t perform that action at this time.
0 commit comments