mirror of
https://github.com/sqlalchemy/sqlalchemy.git
synced 2026-05-16 13:47:20 -04:00
772374735d
tested using pycodestyle version 2.2.0 Fixes: #3885 Change-Id: I5df43adc3aefe318f9eeab72a078247a548ec566 Pull-request: https://github.com/zzzeek/sqlalchemy/pull/343
44 lines
1.2 KiB
Python
44 lines
1.2 KiB
Python
"""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')
|
|
|
|
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
|
|
|
|
x = Column('foo', Integer)
|
|
assert not hasattr(x, '__clause_element__')
|