Code

Opened 6 years ago

Closed 6 years ago

#8029 closed (fixed)

admin_scripts regression tests override PYTHONPATH

Reported by: ramiro 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: UI/UX:

Description

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

======================================================================
FAIL: multiple: manage.py builtin commands succeed if settings are provided as argument
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\ramiro\django-ramiro\tests\regressiontests\admin_scripts\tests.py", line 669, in test_builtin_with_settings
    self.assertNoOutput(err)
  File "C:\ramiro\django-ramiro\tests\regressiontests\admin_scripts\tests.py", 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 "./manage.py", line 11, in <module>
    execute_manager(settings)
  File "C:\ramiro\django-ramiro\django\core\management\__init__.py", line 301, in execute_manager
    utility.execute()
  File "C:\ramiro\django-ramiro\django\core\management\__init__.py", line 248, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "C:\ramiro\django-ramiro\django\core\management\base.py", line 77, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "C:\ramiro\django-ramiro\django\core\management\base.py", line 90, in execute
    self.validate()
  File "C:\ramiro\django-ramiro\django\core\management\base.py", line 117, in validate
    num_errors = get_validation_errors(s, app)
  File "C:\ramiro\django-ramiro\django\core\management\validation.py", line 22, in get_validation_errors
    from django.db import models, connection
  File "C:\ramiro\django-ramiro\django\db\__init__.py", 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 6 years ago.

Download all attachments as: .zip

Change History (3)

Changed 6 years ago by ramiro

comment:1 Changed 6 years ago by ramiro

  • Has patch set
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

comment:2 Changed 6 years ago by russellm

  • Resolution set to fixed
  • Status changed from new to closed

(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.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.