File: test_inspect.py

package info (click to toggle)
sqlalchemy 0.9.8%2Bdfsg-0.1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 23,952 kB
  • ctags: 24,534
  • sloc: python: 152,282; ansic: 1,346; makefile: 257; xml: 17
file content (34 lines) | stat: -rw-r--r-- 867 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
"""test the inspection registry system."""

from sqlalchemy import inspect
from sqlalchemy import Table, Column, Integer, MetaData
from sqlalchemy.testing import fixtures
from sqlalchemy.testing import is_


class TestCoreInspection(fixtures.TestBase):

    def test_table(self):
        t = Table('t', MetaData(),
                  Column('x', Integer)
                  )

        is_(inspect(t), t)
        assert t.is_selectable
        is_(t.selectable, t)

    def test_select(self):
        t = Table('t', MetaData(),
                  Column('x', Integer)
                  )
        s = t.select()

        is_(inspect(s), s)
        assert s.is_selectable
        is_(s.selectable, s)

    def test_column_expr(self):
        c = Column('x', Integer)
        is_(inspect(c), c)
        assert not c.is_selectable
        assert not hasattr(c, 'selectable')