Beispiel #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
Beispiel #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
Beispiel #3
0
 def dec(*args, **kwargs):
     sqltap.start(engine, user_context_fn)
     ret_val = fn(*args, **kwargs)
     sqltap.stop(engine)
     return ret_val
Beispiel #4
0
 def __exit__(self, *args, **kwargs):
     sqltap.stop(self.engine)