(self)
| 21 | |
| 22 | class IndexPropertyTest(fixtures.TestBase): |
| 23 | def test_array(self): |
| 24 | Base = declarative_base() |
| 25 | |
| 26 | class A(Base): |
| 27 | __tablename__ = "a" |
| 28 | id = Column("id", Integer, primary_key=True) |
| 29 | array = Column("_array", ARRAY(Integer), default=[]) |
| 30 | first = index_property("array", 0) |
| 31 | tenth = index_property("array", 9) |
| 32 | |
| 33 | a = A(array=[1, 2, 3]) |
| 34 | eq_(a.first, 1) |
| 35 | assert_raises(AttributeError, lambda: a.tenth) |
| 36 | a.first = 100 |
| 37 | eq_(a.first, 100) |
| 38 | eq_(a.array, [100, 2, 3]) |
| 39 | del a.first |
| 40 | eq_(a.first, 2) |
| 41 | |
| 42 | a2 = A(first=5) |
| 43 | eq_(a2.first, 5) |
| 44 | eq_(a2.array, [5]) |
| 45 | |
| 46 | def test_array_longinit(self): |
| 47 | Base = declarative_base() |
nothing calls this directly
no test coverage detected