> > On Fri, Jul 7, 2017 at 3:07 PM, Антонио Антуан <a.ch...@gmail.com > <javascript:>> wrote: > > Looks like it is not possible, isn't it? > > > > -- > > SQLAlchemy - > > The Python SQL Toolkit and Object Relational Mapper > > > > http://www.sqlalchemy.org/ > > > > To post example code, please provide an MCVE: Minimal, Complete, and > Verifiable Example. See http://stackoverflow.com/help/mcve for a full > description. > > --- > > You received this message because you are subscribed to the Google > Groups "sqlalchemy" group. > > To unsubscribe from this group and stop receiving emails from it, send > an email to sqlalchemy+...@googlegroups.com <javascript:>. > > To post to this group, send email to sqlal...@googlegroups.com > <javascript:>. > > Visit this group at https://groups.google.com/group/sqlalchemy. > > For more options, visit https://groups.google.com/d/optout. >
суббота, 8 июля 2017 г., 0:00:02 UTC+3 пользователь Mike Bayer написал: > > oh, sorry, forgot this. > > you need to register a cleanup for each event you add, such as: > > def setUp(self): > event.listen(SomeThing, "some_event", my_handler) > self.addCleanup(event.remove, SomeThing, "some_event", my_handler) > > or whatever mechanism your test suite provides. > > There of course is a way to clear out event handlers globally but > SQLAlchemy reserves the right to use its own handlers internally and > these can't be cleared out without breaking the library. > I don't know (and in case of tests, don't want to know) what events are bound to my model, session and query. So, I want to call something like that: from my_project.model import Session, UsedModel @pytest.fixture(scope='session', autouse=True) def disable_sqla_events(): # setup Session.disable_all_bound_events() UsedModel.disable_all_bound_events() yield # teardown Session.enable_events() UsedModel.enable_events() Looks like such mechanism does not available, so I should implement it. I'd tried to understand, where and how events-objects stored and bouned with particular sessions and models, but I've failed :) -- SQLAlchemy - The Python SQL Toolkit and Object Relational Mapper http://www.sqlalchemy.org/ To post example code, please provide an MCVE: Minimal, Complete, and Verifiable Example. See http://stackoverflow.com/help/mcve for a full description. --- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+unsubscr...@googlegroups.com. To post to this group, send email to sqlalchemy@googlegroups.com. Visit this group at https://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/d/optout.