[TIP] django fixtures

Kumar McMillan kumar.mcmillan at gmail.com
Wed Mar 7 09:24:53 PST 2007


> http://www.djangoproject.com/documentation/testing/#fixtures
> >
> > Hi, Jeff/Kumar,
> >
> > I'm all for this kind of thing, but did the name have to be "fixture"?
> > Isn't this going to get kind of confusing?
>
>  +1 from me.
>
>  Word "fixture" has a well defined meaning within testing domain and it's
> not about CSV.

last time, I checked a "test fixture" was thought of as the same thing
wikipedia calls it today:

http://en.wikipedia.org/wiki/Test_fixture

"Test fixture refers to the fixed state used as a baseline for running
tests in software testing. The purpose of a test fixture is to ensure
that there is a well known and fixed environment in which tests are
run, so that results are repeatable. It's a fancy term for 'sample
data'.

Examples of fixtures:

    * loading a database with a specific, known set of data
    * erasing a hard disk and installing a known clean operating
system installation
    * copying a specific known set of files
"

This is exactly what the fixture module does, with a focus on loading
a database with known data.  It also provides a class called TempIO(),
which creates a temporary file system for you that's automatically
destroyed when the instance goes out of scope:
http://fixture.googlecode.com/svn/trunk/fixture/io.py

...but, testfixture is too long for a module name ;) (and also a
default nose config will try to load tests from it)

-Kumar



More information about the testing-in-python mailing list