[DB-SIG] mocking DB API

M.-A. Lemburg mal at egenix.com
Tue Nov 27 21:15:05 CET 2012


On 26.11.2012 21:31, Peter Eisentraut wrote:
> Is there some kind of ready-to-use way to mock an entire DB-API driver,
> for use in a unit test suite?  The popular "mock" module can only mock
> classes and methods, but not modules, as would be required here.
> 
> As a target to aim for, I'd be interested to see after a test a list or
> count of the execute calls that were made.

I'm not aware of any existing mock module for DB-API drivers,
but given that it's easy to write a module that defines
mock Cursor and Connection classes, it should be
relatively simple to just hack on up with a little
__get/setattr__ magic.

-- 
Marc-Andre Lemburg
eGenix.com

Professional Python Services directly from the Source  (#1, Nov 27 2012)
>>> Python Projects, Consulting and Support ...   http://www.egenix.com/
>>> mxODBC.Zope/Plone.Database.Adapter ...       http://zope.egenix.com/
>>> mxODBC, mxDateTime, mxTextTools ...        http://python.egenix.com/
________________________________________________________________________

::: Try our new mxODBC.Connect Python Database Interface for free ! ::::

   eGenix.com Software, Skills and Services GmbH  Pastor-Loeh-Str.48
    D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
           Registered at Amtsgericht Duesseldorf: HRB 46611
               http://www.egenix.com/company/contact/


More information about the DB-SIG mailing list