On Sat, 2007-07-28 at 19:36 +0300, Andrey Khavryuchenko wrote:
> Russell,
> 
>  RK> On 7/27/07, Andrey Khavryuchenko <[EMAIL PROTECTED]> wrote:
>  >> 
>  >> Then I've paused and wrote DbMock class for django that uses some black
>  >> magic to steal django db connection and substitute it with temporary 
> sqlite
>  >> in-memory db.
> 
>  RK> How is this different to the default Django behavior if you specify
>  RK> SQLite as your database? Can't you get exactly the same behavior by
>  RK> creating a test_settings.py file that contains:
> 
>  RK> from settings import *
>  RK> DATABASE_BACKEND='sqlite'
> 
>  RK> and then run:
> 
>  RK> ./manage.py --settings=test_settings test
> 
>  RK> ?
> 
> Just replied on django-developers: I need database mock to speedup tests.
> Mocking them into in-memory sqlite was the simplest way to reach this w/o
> losing flexibility.

That isn't an answer to the question Russell asked, though. You can get
exactly the same end-effect (using in-memory SQLite) if you specify
SQLite as the database engine in the settings file you use for testing.
Deriving your testing settings file from the main settings file is just
a matter of importing and replacing the right variable.

The advantage of specifying SQLite directly (and the drawback to trying
to "fake it") is that Django won't inadvertently use any MySQL- or
PostgreSQL-specific SQL constructs under the covers when calling the
database. There are places we consider the value of
settings.DATABASE_ENGINE when constructing the SQL and we may leverage
that more in the future.

So what advantages are there to the mocking approach over just replacing
the setting?

Regards,
Malcolm




--~--~---------~--~----~------------~-------~--~----~
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