manage.py test without using a database?

15 views
Skip to first unread message

Bo Shi

unread,
Dec 30, 2008, 5:08:16 PM12/30/08
to Django users
Hi,

One of our django applications does not use django's ORM. Is there a
way to run

./manage.py test my_app

Such that it does not perform test database setup?


Thanks,
Bo

Russell Keith-Magee

unread,
Jan 1, 2009, 1:50:11 AM1/1/09
to django...@googlegroups.com

There are two ways that you could do this.

The first would be to define a custom test runner that skipped the
database setup phase. django/test/simple/run_tests() will give you a
model for what needs to be in a test runner; take a copy of this
method (removing the database setup portions) and follow the
instructions in [1]

The second approach would be to define a dummy database backend that
didn't complain about a database not being defined.
django/db/backends/dummy gives you a starting point for this.

Either way, you will need to make changes to your settings file.
Neither of these approaches will fall in to the "if I'm only testing
my_app, don't bother setting up the database, otherwise set up the
database as normal" category.

[1] http://docs.djangoproject.com/en/dev/topics/testing/#using-different-testing-frameworks

Yours
Russ Magee %-)

Bo Shi

unread,
Jan 5, 2009, 3:49:13 PM1/5/09
to Django users
Thanks Russell, the former works great (I was hoping, in my infinite
laziness, that there was an undocumented command line switch :-P).

Regards,
Bo

On Jan 1, 1:50 am, "Russell Keith-Magee" <freakboy3...@gmail.com>
wrote:
> [1]http://docs.djangoproject.com/en/dev/topics/testing/#using-different-...
>
> Yours
> Russ Magee %-)
Reply all
Reply to author
Forward
0 new messages