diff options
| author | Jeong YunWon <jeong@youknowone.org> | 2016-07-03 21:45:15 +0900 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2016-07-05 18:24:47 -0400 |
| commit | 5a2d2f47d6681ce3085f4d4e4a8d384eb442c96f (patch) | |
| tree | 05dd2d817e6a0339ecaaba9db7f635b0b91a3d4d /test/ext/test_indexable.py | |
| parent | 7c8c124dbe71602daed471e43af45051c5626c09 (diff) | |
| download | sqlalchemy-5a2d2f47d6681ce3085f4d4e4a8d384eb442c96f.tar.gz | |
`index_property` catches IndexError as well as KeyError
It was raising AttributeError for key accessing in dict,
but raising IndexError for index accessing in array.
Change-Id: I58a2252a9e8d7f78cabcefcbe7223a4f3a729115
Diffstat (limited to 'test/ext/test_indexable.py')
| -rw-r--r-- | test/ext/test_indexable.py | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/test/ext/test_indexable.py b/test/ext/test_indexable.py index c8346e4c3..56f2e1786 100644 --- a/test/ext/test_indexable.py +++ b/test/ext/test_indexable.py @@ -23,9 +23,11 @@ class IndexPropertyTest(fixtures.TestBase): array = Column('_array', ARRAY(Integer), default=[]) first = index_property('array', 0) + tenth = index_property('array', 9) a = A(array=[1, 2, 3]) eq_(a.first, 1) + assert_raises(AttributeError, lambda: a.tenth) a.first = 100 eq_(a.first, 100) eq_(a.array, [100, 2, 3]) @@ -89,7 +91,7 @@ class IndexPropertyTest(fixtures.TestBase): assert_raises(AttributeError, delattr, a, "first") - def test_get_index_error(self): + def test_get_attribute_error(self): Base = declarative_base() class A(Base): @@ -99,7 +101,7 @@ class IndexPropertyTest(fixtures.TestBase): first = index_property('array', 1) a = A(array=[]) - assert_raises(IndexError, lambda: a.first) + assert_raises(AttributeError, lambda: a.first) def test_set_immutable(self): Base = declarative_base() |
