launchpad-dev team mailing list archive
-
launchpad-dev team
-
Mailing list archive
-
Message #08004
Re: New tricks for StormStatementRecorder
On Friday 23 September 2011 18:22:11 Gary Poster wrote:
> from lp.testing import StormStatementRecorder
>
> with StormStatementRecorder() as recorder:
> ...code that touches the DB goes here...
>
> print recorder
This is cool!
> You can conditionally get tracebacks by passing a callable that receives a
> SQL query string and returns a boolean True if a traceback should be
> collected, and False if it should not. The SQL will be normalized to
> capitalization and space normalized. For example,
> StormStatementRecorder(lambda sql: 'STRUCTURALSUBSCRIPTION' in sql) would
> get you tracebacks when the SQL has something to do with structural
> subscriptons.
But this is awesomely unbelieveably useful, thanks Gary!
References