l.t.StormStatementRecorder : class documentation

Part of lp.testing View In Hierarchy

A Storm tracer to record all database queries.

Use the HasQueryCount matcher to check that code makes efficient use
of the database.

Similar to `RequestTimelineCollector`, but can operate outside a web
request context and only collects Storm queries.

It also meets the context manager protocol, so you can gather queries
with StormStatementRecorder() as recorder:
    do somestuff
self.assertThat(recorder, HasQueryCount(LessThan(42)))

This also can be useful for investigation, such as in make harness.
Try printing it after you have collected some queries.  You can
even collect tracebacks, passing True to "tracebacks_if" for tracebacks
of every SQL query, or a callable that takes the SQL query string and
returns a boolean decision as to whether a traceback is desired.
Method __init__ Undocumented
Method queries Undocumented
Method count Undocumented
Method statements Undocumented
Method __enter__ Undocumented
Method __exit__ Undocumented
Method __str__ Undocumented
def __init__(self, tracebacks_if=False):
def queries(self):
def count(self):
def statements(self):
def __enter__(self):
def __exit__(self, exc_type, exc_value, tb):
def __str__(self):
API Documentation for Launchpad, generated by pydoctor at 2020-08-07 00:00:07.