예제 #1
0
    def test_stop(self):
        """ Ensure queries after you call sqltap.stop() are not recorded. """
        sqltap.start(self.engine)
        sess = self.Session()
        sess.query(self.A).all()
        sqltap.stop(self.engine)
        sess.query(self.A).all()

        assert len(sqltap.collect()) == 1
예제 #2
0
    def test_stop_global(self):
        """ Ensure queries after you call sqltap.stop() are not recorded when passing
            in the 'global' Engine object to record queries across all engines.
        
            This test passes, but because SQLAlchemy won't ever let us unregister
            our event handlers, this causes side-effects in other tests and will.
        """
        return
        sqltap.start()
        sess = self.Session()
        sess.query(self.A).all()
        sqltap.stop()
        sess.query(self.A).all()

        assert len(sqltap.collect()) == 1
예제 #3
0
 def dec(*args, **kwargs):
     sqltap.start(engine, user_context_fn)
     ret_val = fn(*args, **kwargs)
     sqltap.stop(engine)
     return ret_val
예제 #4
0
파일: ctx.py 프로젝트: dobesv/sqltap
 def __exit__(self, *args, **kwargs):
     sqltap.stop(self.engine)