Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed #7715 -- Modified the admin_scripts tests to do an app level im…

…port, rather than a project level import. This removes the potential for conflict between the admin script tests and the settings for the test suite itself. Thanks to Malcolm Tredinnick for his help hunting this one down.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@7887 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 4516233f9ef3048735f85703f8dc515160e79de4 1 parent c742afb
@freakboy3742 freakboy3742 authored
Showing with 39 additions and 39 deletions.
  1. +39 −39 tests/regressiontests/admin_scripts/tests.py
View
78 tests/regressiontests/admin_scripts/tests.py
@@ -29,7 +29,7 @@ def write_settings(self, filename, apps=None):
settings_file.write("%s = '%s'\n" % (s, str(getattr(settings,s))))
if apps is None:
- apps = ['django.contrib.auth', 'django.contrib.contenttypes', 'regressiontests.admin_scripts']
+ apps = ['django.contrib.auth', 'django.contrib.contenttypes', 'admin_scripts']
if apps:
settings_file.write("INSTALLED_APPS = %s\n" % apps)
@@ -66,8 +66,8 @@ def run_test(self, script, args, settings_file=None, apps=None):
elif 'DJANGO_SETTINGS_MODULE' in os.environ:
del os.environ['DJANGO_SETTINGS_MODULE']
- os.environ['PYTHONPATH'] = os.pathsep.join([project_dir,base_dir])
-
+ os.environ['PYTHONPATH'] = os.pathsep.join([test_dir,base_dir])
+
# Move to the test directory and run
os.chdir(test_dir)
stdin, stdout, stderr = os.popen3(cmd)
@@ -129,17 +129,17 @@ def test_builtin_command(self):
def test_builtin_with_bad_settings(self):
"no settings: django-admin builtin commands fail if settings file (from argument) doesn't exist"
- args = ['sqlall','--settings=regressiontests.bad_settings', 'admin_scripts']
+ args = ['sqlall','--settings=bad_settings', 'admin_scripts']
out, err = self.run_django_admin(args)
self.assertNoOutput(out)
- self.assertOutput(err, "Could not import settings 'regressiontests.bad_settings'")
+ self.assertOutput(err, "Could not import settings 'bad_settings'")
def test_builtin_with_bad_environment(self):
"no settings: django-admin builtin commands fail if settings file (from environment) doesn't exist"
args = ['sqlall','admin_scripts']
- out, err = self.run_django_admin(args,'regressiontests.bad_settings')
+ out, err = self.run_django_admin(args,'bad_settings')
self.assertNoOutput(out)
- self.assertOutput(err, "Could not import settings 'regressiontests.bad_settings'")
+ self.assertOutput(err, "Could not import settings 'bad_settings'")
class DjangoAdminDefaultSettings(AdminScriptTestCase):
@@ -161,7 +161,7 @@ def test_builtin_command(self):
def test_builtin_with_settings(self):
"default: django-admin builtin commands succeed if settings are provided as argument"
- args = ['sqlall','--settings=regressiontests.settings', 'admin_scripts']
+ args = ['sqlall','--settings=settings', 'admin_scripts']
out, err = self.run_django_admin(args)
self.assertNoOutput(err)
self.assertOutput(out, 'CREATE TABLE')
@@ -169,23 +169,23 @@ def test_builtin_with_settings(self):
def test_builtin_with_environment(self):
"default: django-admin builtin commands succeed if settings are provided in the environment"
args = ['sqlall','admin_scripts']
- out, err = self.run_django_admin(args,'regressiontests.settings')
+ out, err = self.run_django_admin(args,'settings')
self.assertNoOutput(err)
self.assertOutput(out, 'CREATE TABLE')
def test_builtin_with_bad_settings(self):
"default: django-admin builtin commands fail if settings file (from argument) doesn't exist"
- args = ['sqlall','--settings=regressiontests.bad_settings', 'admin_scripts']
+ args = ['sqlall','--settings=bad_settings', 'admin_scripts']
out, err = self.run_django_admin(args)
self.assertNoOutput(out)
- self.assertOutput(err, "Could not import settings 'regressiontests.bad_settings'")
+ self.assertOutput(err, "Could not import settings 'bad_settings'")
def test_builtin_with_bad_environment(self):
"default: django-admin builtin commands fail if settings file (from environment) doesn't exist"
args = ['sqlall','admin_scripts']
- out, err = self.run_django_admin(args,'regressiontests.bad_settings')
+ out, err = self.run_django_admin(args,'bad_settings')
self.assertNoOutput(out)
- self.assertOutput(err, "Could not import settings 'regressiontests.bad_settings'")
+ self.assertOutput(err, "Could not import settings 'bad_settings'")
def test_custom_command(self):
"default: django-admin can't execute user commands"
@@ -196,7 +196,7 @@ def test_custom_command(self):
def test_custom_command_with_settings(self):
"default: django-admin can't execute user commands, even if settings are provided as argument"
- args = ['noargs_command', '--settings=regressiontests.settings']
+ args = ['noargs_command', '--settings=settings']
out, err = self.run_django_admin(args)
self.assertNoOutput(out)
self.assertOutput(err, "Unknown command: 'noargs_command'")
@@ -204,7 +204,7 @@ def test_custom_command_with_settings(self):
def test_custom_command_with_environment(self):
"default: django-admin can't execute user commands, even if settings are provided in environment"
args = ['noargs_command']
- out, err = self.run_django_admin(args,'regressiontests.settings')
+ out, err = self.run_django_admin(args,'settings')
self.assertNoOutput(out)
self.assertOutput(err, "Unknown command: 'noargs_command'")
@@ -227,7 +227,7 @@ def test_builtin_command(self):
def test_builtin_with_settings(self):
"minimal: django-admin builtin commands fail if settings are provided as argument"
- args = ['sqlall','--settings=regressiontests.settings', 'admin_scripts']
+ args = ['sqlall','--settings=settings', 'admin_scripts']
out, err = self.run_django_admin(args)
self.assertNoOutput(out)
self.assertOutput(err, 'App with label admin_scripts could not be found')
@@ -235,23 +235,23 @@ def test_builtin_with_settings(self):
def test_builtin_with_environment(self):
"minimal: django-admin builtin commands fail if settings are provided in the environment"
args = ['sqlall','admin_scripts']
- out, err = self.run_django_admin(args,'regressiontests.settings')
+ out, err = self.run_django_admin(args,'settings')
self.assertNoOutput(out)
self.assertOutput(err, 'App with label admin_scripts could not be found')
def test_builtin_with_bad_settings(self):
"minimal: django-admin builtin commands fail if settings file (from argument) doesn't exist"
- args = ['sqlall','--settings=regressiontests.bad_settings', 'admin_scripts']
+ args = ['sqlall','--settings=bad_settings', 'admin_scripts']
out, err = self.run_django_admin(args)
self.assertNoOutput(out)
- self.assertOutput(err, "Could not import settings 'regressiontests.bad_settings'")
+ self.assertOutput(err, "Could not import settings 'bad_settings'")
def test_builtin_with_bad_environment(self):
"minimal: django-admin builtin commands fail if settings file (from environment) doesn't exist"
args = ['sqlall','admin_scripts']
- out, err = self.run_django_admin(args,'regressiontests.bad_settings')
+ out, err = self.run_django_admin(args,'bad_settings')
self.assertNoOutput(out)
- self.assertOutput(err, "Could not import settings 'regressiontests.bad_settings'")
+ self.assertOutput(err, "Could not import settings 'bad_settings'")
def test_custom_command(self):
"minimal: django-admin can't execute user commands"
@@ -262,7 +262,7 @@ def test_custom_command(self):
def test_custom_command_with_settings(self):
"minimal: django-admin can't execute user commands, even if settings are provided as argument"
- args = ['noargs_command', '--settings=regressiontests.settings']
+ args = ['noargs_command', '--settings=settings']
out, err = self.run_django_admin(args)
self.assertNoOutput(out)
self.assertOutput(err, "Unknown command: 'noargs_command'")
@@ -270,7 +270,7 @@ def test_custom_command_with_settings(self):
def test_custom_command_with_environment(self):
"minimal: django-admin can't execute user commands, even if settings are provided in environment"
args = ['noargs_command']
- out, err = self.run_django_admin(args,'regressiontests.settings')
+ out, err = self.run_django_admin(args,'settings')
self.assertNoOutput(out)
self.assertOutput(err, "Unknown command: 'noargs_command'")
@@ -293,7 +293,7 @@ def test_builtin_command(self):
def test_builtin_with_settings(self):
"alternate: django-admin builtin commands succeed if settings are provided as argument"
- args = ['sqlall','--settings=regressiontests.alternate_settings', 'admin_scripts']
+ args = ['sqlall','--settings=alternate_settings', 'admin_scripts']
out, err = self.run_django_admin(args)
self.assertNoOutput(err)
self.assertOutput(out, 'CREATE TABLE')
@@ -301,23 +301,23 @@ def test_builtin_with_settings(self):
def test_builtin_with_environment(self):
"alternate: django-admin builtin commands succeed if settings are provided in the environment"
args = ['sqlall','admin_scripts']
- out, err = self.run_django_admin(args,'regressiontests.alternate_settings')
+ out, err = self.run_django_admin(args,'alternate_settings')
self.assertNoOutput(err)
self.assertOutput(out, 'CREATE TABLE')
def test_builtin_with_bad_settings(self):
"alternate: django-admin builtin commands fail if settings file (from argument) doesn't exist"
- args = ['sqlall','--settings=regressiontests.bad_settings', 'admin_scripts']
+ args = ['sqlall','--settings=bad_settings', 'admin_scripts']
out, err = self.run_django_admin(args)
self.assertNoOutput(out)
- self.assertOutput(err, "Could not import settings 'regressiontests.bad_settings'")
+ self.assertOutput(err, "Could not import settings 'bad_settings'")
def test_builtin_with_bad_environment(self):
"alternate: django-admin builtin commands fail if settings file (from environment) doesn't exist"
args = ['sqlall','admin_scripts']
- out, err = self.run_django_admin(args,'regressiontests.bad_settings')
+ out, err = self.run_django_admin(args,'bad_settings')
self.assertNoOutput(out)
- self.assertOutput(err, "Could not import settings 'regressiontests.bad_settings'")
+ self.assertOutput(err, "Could not import settings 'bad_settings'")
def test_custom_command(self):
"alternate: django-admin can't execute user commands"
@@ -328,7 +328,7 @@ def test_custom_command(self):
def test_custom_command_with_settings(self):
"alternate: django-admin can't execute user commands, even if settings are provided as argument"
- args = ['noargs_command', '--settings=regressiontests.alternate_settings']
+ args = ['noargs_command', '--settings=alternate_settings']
out, err = self.run_django_admin(args)
self.assertNoOutput(out)
self.assertOutput(err, "Unknown command: 'noargs_command'")
@@ -336,7 +336,7 @@ def test_custom_command_with_settings(self):
def test_custom_command_with_environment(self):
"alternate: django-admin can't execute user commands, even if settings are provided in environment"
args = ['noargs_command']
- out, err = self.run_django_admin(args,'regressiontests.alternate_settings')
+ out, err = self.run_django_admin(args,'alternate_settings')
self.assertNoOutput(out)
self.assertOutput(err, "Unknown command: 'noargs_command'")
@@ -364,7 +364,7 @@ def test_builtin_command(self):
def test_builtin_with_settings(self):
"alternate: django-admin builtin commands succeed if settings are provided as argument"
- args = ['sqlall','--settings=regressiontests.alternate_settings', 'admin_scripts']
+ args = ['sqlall','--settings=alternate_settings', 'admin_scripts']
out, err = self.run_django_admin(args)
self.assertNoOutput(err)
self.assertOutput(out, 'CREATE TABLE')
@@ -372,22 +372,22 @@ def test_builtin_with_settings(self):
def test_builtin_with_environment(self):
"alternate: django-admin builtin commands succeed if settings are provided in the environment"
args = ['sqlall','admin_scripts']
- out, err = self.run_django_admin(args,'regressiontests.alternate_settings')
+ out, err = self.run_django_admin(args,'alternate_settings')
self.assertNoOutput(err)
self.assertOutput(out, 'CREATE TABLE')
def test_builtin_with_bad_settings(self):
"alternate: django-admin builtin commands fail if settings file (from argument) doesn't exist"
- args = ['sqlall','--settings=regressiontests.bad_settings', 'admin_scripts']
+ args = ['sqlall','--settings=bad_settings', 'admin_scripts']
out, err = self.run_django_admin(args)
- self.assertOutput(err, "Could not import settings 'regressiontests.bad_settings'")
+ self.assertOutput(err, "Could not import settings 'bad_settings'")
def test_builtin_with_bad_environment(self):
"alternate: django-admin builtin commands fail if settings file (from environment) doesn't exist"
args = ['sqlall','admin_scripts']
- out, err = self.run_django_admin(args,'regressiontests.bad_settings')
+ out, err = self.run_django_admin(args,'bad_settings')
self.assertNoOutput(out)
- self.assertOutput(err, "Could not import settings 'regressiontests.bad_settings'")
+ self.assertOutput(err, "Could not import settings 'bad_settings'")
def test_custom_command(self):
"alternate: django-admin can't execute user commands"
@@ -398,7 +398,7 @@ def test_custom_command(self):
def test_custom_command_with_settings(self):
"alternate: django-admin can't execute user commands, even if settings are provided as argument"
- args = ['noargs_command', '--settings=regressiontests.alternate_settings']
+ args = ['noargs_command', '--settings=alternate_settings']
out, err = self.run_django_admin(args)
self.assertNoOutput(out)
self.assertOutput(err, "Unknown command: 'noargs_command'")
@@ -406,7 +406,7 @@ def test_custom_command_with_settings(self):
def test_custom_command_with_environment(self):
"alternate: django-admin can't execute user commands, even if settings are provided in environment"
args = ['noargs_command']
- out, err = self.run_django_admin(args,'regressiontests.alternate_settings')
+ out, err = self.run_django_admin(args,'alternate_settings')
self.assertNoOutput(out)
self.assertOutput(err, "Unknown command: 'noargs_command'")

0 comments on commit 4516233

Please sign in to comment.
Something went wrong with that request. Please try again.