MCPcopy Create free account
hub / github.com/sqlalchemy/sqlalchemy / test_attribute_sanity

Method test_attribute_sanity

test/sql/test_compiler.py:257–291  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

255 assert not hasattr(c1, "__dict__")
256
257 def test_attribute_sanity(self):
258 assert hasattr(table1, "c")
259 assert hasattr(table1.select().subquery(), "c")
260 assert not hasattr(table1.c.myid.self_group(), "columns")
261 assert not hasattr(table1.c.myid, "columns")
262 assert not hasattr(table1.c.myid, "c")
263 assert not hasattr(table1.select().subquery().c.myid, "c")
264 assert not hasattr(table1.select().subquery().c.myid, "columns")
265 assert not hasattr(table1.alias().c.myid, "columns")
266 assert not hasattr(table1.alias().c.myid, "c")
267 with testing.expect_deprecated(
268 "The SelectBase.c and SelectBase.columns attributes are "
269 "deprecated"
270 ):
271 assert hasattr(table1.select(), "c")
272
273 assert_raises_message(
274 exc.InvalidRequestError,
275 "Scalar Select expression has no "
276 "columns; use this object directly within a "
277 "column-level expression.",
278 getattr,
279 select(table1.c.myid).scalar_subquery().self_group(),
280 "columns",
281 )
282
283 assert_raises_message(
284 exc.InvalidRequestError,
285 "Scalar Select expression has no "
286 "columns; use this object directly within a "
287 "column-level expression.",
288 getattr,
289 select(table1.c.myid).scalar_subquery(),
290 "columns",
291 )
292
293 def test_table_select(self):
294 self.assert_compile(

Callers

nothing calls this directly

Calls 7

assert_raises_messageFunction · 0.90
selectFunction · 0.90
subqueryMethod · 0.45
selectMethod · 0.45
self_groupMethod · 0.45
aliasMethod · 0.45
scalar_subqueryMethod · 0.45

Tested by

no test coverage detected