Django

Code

Ticket #5453 (closed: fixed)

Opened 10 months ago

Last modified 10 months ago

Test database used in runtests.py does not match documented behavior

Reported by: mcroydon Assigned to: nobody
Milestone: Component: Unit test system
Version: SVN Keywords:
Cc: Triage Stage: Unreviewed
Has patch: 0 Needs documentation:
Needs tests: Patch needs improvement:

Description

As of [6184], it is impossible to set TEST_DATABASE_NAME and have that be used when tests/runtests.py is run. The test runner overrides settings.TEST_DATABASE_NAME with the hard-coded value 'django_test_db', so that even if TEST_DATABASE_NAME is set, it will be ignored:

mattbookpro:~/code/python/sprint/django-trunk mcroydon$ python tests/runtests.py --settings=sprint.settings
Got an error creating the test database: database "django_test_db" already exists

After applying the patch, what actually happens matches the test documentation. If your DATABASE_NAME is "mydatabase" and TEST_DATABASE_NAME is not set, the test framework will use "test_mydatabase":

mattbookpro:~/code/python/sprint/django-trunk mcroydon$ python tests/runtests.py --settings=sprint.settings    
Got an error creating the test database: database "test_mydatabase" already exists

If you set TEST_DATABASE_NAME to "arbitrarytestdb" that database will be used for testing instead:

mattbookpro:~/code/python/sprint/django-trunk mcroydon$ python tests/runtests.py --settings=sprint.settings
Got an error creating the test database: database "arbitrarytestdb" already exists

Attachments

test_database_name.diff (1.2 kB) - added by mcroydon on 09/14/07 07:35:26.
Patch to make TEST_DATABASE_NAME behavior match documentation

Change History

09/14/07 07:35:26 changed by mcroydon

  • attachment test_database_name.diff added.

Patch to make TEST_DATABASE_NAME behavior match documentation

09/14/07 07:48:11 changed by mtredinnick

  • status changed from new to closed.
  • resolution set to fixed.

(In [6186]) Fixed #5453 -- Fixed TEST_DATABASE_NAME handling to match documentation. Thanks, Matt Croydon.


Add/Change #5453 (Test database used in runtests.py does not match documented behavior)




Change Properties
Action