MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / _fixture

Method _fixture

test/ext/test_baked.py:385–407  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

383
384 @contextlib.contextmanager
385 def _fixture(self):
386 from sqlalchemy import event
387
388 User = self.classes.User
389
390 with testing.db.connect() as conn:
391
392 @event.listens_for(conn, "before_execute")
393 def before_execute(
394 conn, clauseelement, multiparams, params, execution_options
395 ):
396 # execution options are kind of moving around a bit,
397 # test both places
398 assert (
399 "yes" in clauseelement._execution_options
400 or "yes" in execution_options
401 )
402
403 bq = self.bakery(lambda s: s.query(User.id).order_by(User.id))
404
405 sess = Session(conn)
406
407 yield sess, bq
408
409 def test_first(self):
410 with self._fixture() as (sess, bq):

Callers 4

test_firstMethod · 0.95
test_iterMethod · 0.95
test_spoiledMethod · 0.95
test_getMethod · 0.95

Calls 5

SessionClass · 0.90
bakeryMethod · 0.80
connectMethod · 0.45
order_byMethod · 0.45
queryMethod · 0.45

Tested by

no test coverage detected