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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
"""test the inspection registry system."""
from sqlalchemy import Column
from sqlalchemy import inspect
from sqlalchemy import Integer
from sqlalchemy import MetaData
from sqlalchemy import Table
from sqlalchemy.sql import ClauseElement
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")
def test_no_clause_element_on_clauseelement(self):
# re [ticket:3802], there are in the wild examples
# of looping over __clause_element__, therefore the
# absence of __clause_element__ as a test for "this is the clause
# element" must be maintained
class Foo(ClauseElement):
pass
assert not hasattr(Foo(), "__clause_element__")
def test_col_now_has_a_clauseelement(self):
x = Column("foo", Integer)
assert hasattr(x, "__clause_element__")
|