# also ``_validate_column_name``, where such a mechanism is
# already implemented).
if not hasattr(current, bit):
- raise ValueError("Could not resolve %s from %s" % (bit, name))
+ raise ValueError("Could not resolve %s from %s" % (bit, boundcol.accessor))
current = getattr(current, bit)
if callable(current):
test_country_table(countries)
+def test_invalid_accessor():
+ """Test that a column being backed by a non-existent model property
+ is handled correctly.
+
+ Regression-Test: There used to be a NameError here.
+ """
+ class CountryTable(tables.ModelTable):
+ name = tables.Column(data='something-i-made-up')
+ countries = CountryTable(Country)
+ assert_raises(ValueError, countries[0].__getitem__, 'name')
+
+
def test_caches():
"""Make sure the caches work for model tables as well (parts are
reimplemented).
assert [row['example_domain'] for row in countries] == \
[row['null'] for row in countries]
+
def test_relationships():
"""Test relationship spanning."""