Opened 18 years ago
Closed 18 years ago
#5453 closed (fixed)
Test database used in runtests.py does not match documented behavior
| Reported by: | mcroydon | Owned by: | nobody |
|---|---|---|---|
| Component: | Testing framework | Version: | dev |
| Severity: | Keywords: | ||
| Cc: | Triage Stage: | Unreviewed | |
| Has patch: | no | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
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 (1)
Change History (2)
by , 18 years ago
| Attachment: | test_database_name.diff added |
|---|
comment:1 by , 18 years ago
| Resolution: | → fixed |
|---|---|
| Status: | new → closed |
Patch to make TEST_DATABASE_NAME behavior match documentation