On 11/23/07, Atsushi Suga <[EMAIL PROTECTED]> wrote:
>
> I have a question abut database flush condition.
> in django/test/testcases.py TestCase._pre_setup()
>
> forrow is _pre_setup() comment
> """
> ...
> If the Test Case class has a 'fixtures' member, clearing the
> database and installing the named fixtures at the start of each
> test.
> ...
> """
>
> Comment of this method looks like this "if class doesn't have a
> 'fixtures' member, doesn't clear the database.".
>
> But in actually, the database is cleared every time if class does not
> have a 'fixtures' member ,too.

In this case, the method comment is in error. The user documentation
for test cases correctly describes the intended and actual behaviour
of the method.

The purpose of a django.test.TestCase is to guarantee the state of the
database at the start of each test; this can only be acheived if a
flush happens every time.

Without this flush, there could be all sorts of unexpected
consequences and leakages between tests - e.g., if test 1 uses the
number of objects of model X as a test condition, and test 2 creates
an instance of model X, then the order in which test 1 and test 2 are
executed becomes significant.

The correct fix here is to clarify the method comment.

Yours,
Russ Magee %-)

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

Reply via email to