Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

[Django]: nose-django を試してみた。

testing tool nose の Django 対応版 nose-django 。 settings は読み込めたものの TypeError や NameError が山ほど。 なにか使い方が間違っているんだろうなぁ。

$ cd site-packages
$ sudo svn checkout http://nose-django.googlecode.com/svn/trunk/ nose-django
$ cd nose-django
$ sudo python setup.py install

$ nosetests --help
usage: nosetests [options] [names]

    nose provides an alternate test discovery and running process for
    unittest, one that is intended to mimic the behavior of py.test as much as
    is reasonably possible without resorting to magic.
...

--with-django         Enable plugin NoseDjango:  Enable to set up django
                      test environment before running all tests, and tear it
                      down after all tests. If the django database engine in
                      use is not sqlite3, one or both of --django-test-db or
                      django-test-schema must be specified.  Note that your
                      django project must be on PYTHONPATH for the settings
                      file to be loaded. The plugin will help out by placing
                      the nose working dir into sys.path if it isn't already
                      there, unless the -P (--no-path-adjustment) argument
                      is set.  [NOSE_WITH_DJANGO]
--django-settings=DJANGO_SETTINGS
                      Set module as the DJANGO_SETTINGS_MODULE environment
                      variable.
--django-test-db=DJANGO_TEST_DB
                      Create this database for use in tests and drop it
                      after tests have run. May be combined with --django-
                      test-schema option for databases that support schemas.
                      This option is not used for sqlite3 connections.
                      PLEASE NOTE that if the test database already exists,
                      the test run will be immediately cancelled.
                      [NOSE_DJANGO_TEST_DB]
--django-test-schema=DJANGO_TEST_SCHEMA
                      Create this schema for use in tests and drop it after
                      tests have run. May be combined with --django-test-db;
                      otherwise, test schema will be created in the database
                      named by DATABASE_NAME in the active django settings.
                      This option is not used for sqlite3 connections.
                      PLEASE NOTE that if the specified schema already
                      exists in the target database, the test run will be
                      immediately cancelled. [NOSE_DJANGO_TEST_SCHEMA]
...

$ cd site-packages
$ cat mydj.pth
/path-to/myproject
$ export DJANGO_SETTINGS=myproject.settings

$ cd myproject
$ nosetests --doctest-tests --with-doctest --with-django --django-settings=DJANGO_SETTINGS
.F
======================================================================
FAIL: Doctest: app.tests
----------------------------------------------------------------------
Traceback (most recent call last):
...
----------------------------------------------------------------------
Ran 2 tests in 9.476s

FAILED (failures=1)

Thu, 8 Mar 2007 19:28:36 +0900

author:
Posted on