[TIP] Using DB on tests without orm
geoff.bache at gmail.com
Fri Jul 22 00:37:54 PDT 2011
On Thu, Jul 21, 2011 at 9:07 PM, marrese at gmail.com <marrese at gmail.com> wrote:
> I'm lookin for a better way to do testing in the project I'm currently
> working on.
> We have a project that uses MySQL as database, and we have in there a
> set of databases we use on development and a single database that is
> used for the tests. This test database includes many tables from the
> development databases.
> I didn't like this schema, but didn't find a better solution that
> suits our needs in a better way.
> Today we decided to look for a better approach.
> The first thing I thought about was to use sqlite3 and do all the
> testing in there, but I can't find a decent way to migrate data
> between mysql and sqlite (and I think I will have to do this on
> regular basis)
> Mocks are good, but we have tons of tables so they are annoying to
> maintain (don't get me wrong, we are using them, just not for
> Because of implementation decisions, we use straight db calls instead of an ORM.
> Does anyone have a TIP ( :) ) about this?
My suggestion / shameless plug is to take a look at my CaptureMock
(http://www.texttest.org/index.php?page=capturemock). This might
address your "mock problems", because the idea of it is to generate
mocks from real Python code, so when your DB schema changes you can
just regenerate them all from a development database and don't have to
port lots of code.
It is fairly new though, so don't be surprised if you find an issue or two...
More information about the testing-in-python