Recently I tried using Sqlite instead of Postgres as the database
engine for testing one of my django applications.
My observations follow:

1) Tests ran significantly faster[1].
2) Some tests failed in Windows while some of them failed in both
Windows and Linux. All tests succeeded in both operating systems when
I switched back to Postgres.
3) Tests that failed in both operating systems had to do with Sqlite's
way of handling decimal types.
4) I don't have any explanation for why some tests failed only in
Windows.

Here is a sample test case that failed *only in Windows*.

Model:
from django.contrib.auth.models import User

class Book(models.Model):
    users = models.ManyToManyField(User)
    <snip>

View:
def list_books(request, username):
    books = Book.objects.filter(users__username__exact =
username).order_by('name')
    <snip>

One the tests compares the number of books returned for various users.
Apparently the join is not working and ALL books are being picked up
instead of books for a given username. Interestingly enough tests
succeeded when I changed the view as follows:

def list_books(request, username):
    user  = User.objects.get(username = username)
    books = Book.objects.filter(users = user).order_by('name')
    <snip>

What am I doing wrong here? Why does the join work in Linux while not
in Windows? Also, is there a way to examine the data in an Sqlite test
database[2] while running tests? I know I can do this in Postgres by
adding a breakpoint somewhere in the test suite and then using psql to
access my test_* database. Can something similar be done for Sqlite?

[1] Executing 110 tests took 30s as against 445s on a Windows XP box;
51s versus 180s on a much older box running Ubuntu Feisty
[2] I use the following settings for running tests:
from settings import *

DATABASE_ENGINE = 'sqlite3'    # 'postgresql', 'mysql', 'sqlite3' or
'ado_mssql'.
DATABASE_NAME = ''             # Or path to database file if using
sqlite3.
DATABASE_USER = ''             # Not used with sqlite3.
DATABASE_PASSWORD = ''         # Not used with sqlite3.
DATABASE_HOST = ''             # Set to empty string for localhost.
Not used with sqlite3.
DATABASE_PORT = ''             # Set to empty string for default. Not
used with sqlite3.

--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to