1"""test the inspection registry system.""" 2 3from sqlalchemy import Column 4from sqlalchemy import inspect 5from sqlalchemy import Integer 6from sqlalchemy import MetaData 7from sqlalchemy import Table 8from sqlalchemy.testing import fixtures 9from sqlalchemy.testing import is_ 10 11 12class TestCoreInspection(fixtures.TestBase): 13 def test_table(self): 14 t = Table("t", MetaData(), Column("x", Integer)) 15 16 is_(inspect(t), t) 17 assert t.is_selectable 18 is_(t.selectable, t) 19 20 def test_select(self): 21 t = Table("t", MetaData(), Column("x", Integer)) 22 s = t.select() 23 24 is_(inspect(s), s) 25 assert s.is_selectable 26 is_(s.selectable, s) 27 28 def test_column_expr(self): 29 c = Column("x", Integer) 30 is_(inspect(c), c) 31 assert not c.is_selectable 32 assert not hasattr(c, "selectable") 33 34 def test_no_clause_element_on_clauseelement(self): 35 # re [ticket:3802], there are in the wild examples 36 # of looping over __clause_element__, therefore the 37 # absence of __clause_element__ as a test for "this is the clause 38 # element" must be maintained 39 40 x = Column("foo", Integer) 41 assert not hasattr(x, "__clause_element__") 42