On Tue, Jan 6, 2009 at 6:05 PM, Malcolm Tredinnick
<malc...@pointy-stick.com> wrote:
>
> On Tue, 2009-01-06 at 14:51 -0500, Todd O'Bryan wrote:
> [...]
>
>> So, what am I missing? I know this doesn't deal with doctests--the db
>> gets cleaned for all of those, but does anyone see when this is just
>> going to blow up in my face?
>
> For that to work reliably, you would need to deeply know the internals
> of Django to know which calls are going to dirty the database in some
> way. For example, if your tests simulate a user's interactions at all,
> there will be changes to the session.
>
Right. For example, every time a user logs in, the last_login gets
updated. I would say dirties_db = False in most of those cases,
because I just don't check the last_login time in my tests.

> So, sure, it's possible, although duplicates a lot of code, but it's
> also a bit fragile. Russell Keith-Magee and I have had a number of
> conversations over the past couple of years about speeding up the tests
> for Django itself and we keep looking at this one. But, at the end of
> the day, every set of non-significant tests touch the database in some
> way, with very, very few exceptions (template rendering being one such
> exception).
>
> If it works for you, sure, keep going. But when things suddenly start
> failing in interesting ways down the track (when you have 500 tests in
> your suite), expect to set aside time to debug your testing harness
> setup, rather than your tests.
>
Forewarned is forearmed. The worst that could happen is that I have to
switch from extending MyTestCase to django.test.TestCase if I can't
figure out what's causing the problem. I agree it's a little hacky,
but I have such a short attention span... :-)

> There are other plans moving along slowly to speed up the tests for some
> databases (capable databases with proper transaction support :-) ),
> wherein a lot of tests can just run inside a transaction and roll back
> at the end. But there are a few corner cases still to work out there, so
> it's not quite ready yet.
>
Looking forward to it. Thanks for the warnings--I'm sure I will get
bitten at some point.

Todd

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to