Opened 10 years ago

Closed 10 years ago

#8029 closed (fixed)

admin_scripts regression tests override PYTHONPATH

Reported by: Ramiro Morales Owned by: nobody
Component: Testing framework Version: master
Severity: Keywords: DATABASE_BACKEND admin_scripts
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


When running the test suite against a custom external DB backend, the admin_scripts test fail with multiple errors like this:

FAIL: multiple: builtin commands succeed if settings are provided as argument
Traceback (most recent call last):
  File "C:\ramiro\django-ramiro\tests\regressiontests\admin_scripts\", line 669, in test_builtin_with_settings
  File "C:\ramiro\django-ramiro\tests\regressiontests\admin_scripts\", line 109, in assertNoOutput
    self.assertEquals(len(stream), 0, "Stream should be empty: actually contains '%s'" % stream)
AssertionError: Stream should be empty: actually contains 'Traceback (most recent call last):
  File "./", line 11, in <module>
  File "C:\ramiro\django-ramiro\django\core\management\", line 301, in execute_manager
  File "C:\ramiro\django-ramiro\django\core\management\", line 248, in execute
  File "C:\ramiro\django-ramiro\django\core\management\", line 77, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "C:\ramiro\django-ramiro\django\core\management\", line 90, in execute
  File "C:\ramiro\django-ramiro\django\core\management\", line 117, in validate
    num_errors = get_validation_errors(s, app)
  File "C:\ramiro\django-ramiro\django\core\management\", line 22, in get_validation_errors
    from django.db import models, connection
  File "C:\ramiro\django-ramiro\django\db\", line 34, in <module>
    (settings.DATABASE_ENGINE, ", ".join(map(repr, available_backends)))
django.core.exceptions.ImproperlyConfigured: 'sql_server.pyodbc' isn't an available database backend.
Available options are: 'dummy', 'mysql', 'oracle', 'postgresql', 'postgresql_psycopg2', 'sqlite3'

Ran 93 tests in 32.563s

FAILED (failures=25)

Suspicion is that the tests override the PYTHONPATH envvar, and this break things ebcause the documented way of specifying an external backend is adding it's path to PYTHONPATH and setting the DATABASE_ENGINE var of the settings file being used for testing.

It was confirmed by Alex Gaynor who suggested to try the patch attached that solved the problem.

Attachments (1)

admin_scripts.diff (599 bytes) - added by Ramiro Morales 10 years ago.

Download all attachments as: .zip

Change History (3)

Changed 10 years ago by Ramiro Morales

Attachment: admin_scripts.diff added

comment:1 Changed 10 years ago by Ramiro Morales

Has patch: set

comment:2 Changed 10 years ago by Russell Keith-Magee

Resolution: fixed
Status: newclosed

(In [8149]) Fixed #8029 -- Modified admin_scripts test to use the PYTHONPATH from the environment where the test is executed. Thanks to Ramiro and Alex Gaynor for the report.

Note: See TracTickets for help on using tickets.
Back to Top