Renamed some tests and removed references to modeltests/regressiontests.

This commit is contained in:
Florian Apolloner 2013-02-26 13:19:18 +01:00
parent 737a5d71f0
commit 33836cf88d
224 changed files with 384 additions and 376 deletions

View file

@ -25,11 +25,17 @@ from django.utils._os import upath
from django.utils.six import StringIO
from django.test import LiveServerTestCase
test_dir = os.path.dirname(os.path.dirname(upath(__file__)))
test_dir = os.path.join(os.environ['DJANGO_TEST_TEMP_DIR'], 'test_project')
if not os.path.exists(test_dir):
os.mkdir(test_dir)
open(os.path.join(test_dir, '__init__.py'), 'w').close()
custom_templates_dir = os.path.join(os.path.dirname(__file__), 'custom_templates')
class AdminScriptTestCase(unittest.TestCase):
def write_settings(self, filename, apps=None, is_dir=False, sdict=None):
test_dir = os.path.dirname(os.path.dirname(upath(__file__)))
if is_dir:
settings_dir = os.path.join(test_dir, filename)
os.mkdir(settings_dir)
@ -38,7 +44,7 @@ class AdminScriptTestCase(unittest.TestCase):
settings_file_path = os.path.join(test_dir, filename)
with open(settings_file_path, 'w') as settings_file:
settings_file.write('# Settings file automatically generated by regressiontests.admin_scripts test case\n')
settings_file.write('# Settings file automatically generated by admin_scripts test case\n')
exports = [
'DATABASES',
'ROOT_URLCONF',
@ -52,7 +58,7 @@ class AdminScriptTestCase(unittest.TestCase):
settings_file.write("%s = %s\n" % (s, o))
if apps is None:
apps = ['django.contrib.auth', 'django.contrib.contenttypes', 'regressiontests.admin_scripts']
apps = ['django.contrib.auth', 'django.contrib.contenttypes', 'admin_scripts']
settings_file.write("INSTALLED_APPS = %s\n" % apps)
@ -91,16 +97,18 @@ class AdminScriptTestCase(unittest.TestCase):
first_package_re = re.compile(r'(^[^\.]+)\.')
for backend in settings.DATABASES.values():
result = first_package_re.findall(backend['ENGINE'])
if result and result != 'django':
if result and result != ['django']:
backend_pkg = __import__(result[0])
backend_dir = os.path.dirname(backend_pkg.__file__)
paths.append(os.path.dirname(backend_dir))
return paths
def run_test(self, script, args, settings_file=None, apps=None):
test_dir = os.path.dirname(os.path.dirname(__file__))
project_dir = os.path.dirname(test_dir)
project_dir = test_dir
base_dir = os.path.dirname(project_dir)
import django
django_dir = os.path.dirname(os.path.dirname(django.__file__))
tests_dir = os.path.join(django_dir, 'tests')
ext_backend_base_dirs = self._ext_backend_paths()
# Remember the old environment
@ -118,7 +126,7 @@ class AdminScriptTestCase(unittest.TestCase):
os.environ['DJANGO_SETTINGS_MODULE'] = settings_file
elif 'DJANGO_SETTINGS_MODULE' in os.environ:
del os.environ['DJANGO_SETTINGS_MODULE']
python_path = [project_dir, base_dir]
python_path = [project_dir, base_dir, django_dir, tests_dir]
python_path.extend(ext_backend_base_dirs)
os.environ[python_path_var_name] = os.pathsep.join(python_path)
@ -127,7 +135,6 @@ class AdminScriptTestCase(unittest.TestCase):
out, err = subprocess.Popen([sys.executable, script] + args,
stdout=subprocess.PIPE, stderr=subprocess.PIPE,
universal_newlines=True).communicate()
# Restore the old environment
if old_django_settings_module:
os.environ['DJANGO_SETTINGS_MODULE'] = old_django_settings_module
@ -158,7 +165,7 @@ class AdminScriptTestCase(unittest.TestCase):
with open(test_manage_py, 'r') as fp:
manage_py_contents = fp.read()
manage_py_contents = manage_py_contents.replace(
"{{ project_name }}", "regressiontests")
"{{ project_name }}", "test_project")
with open(test_manage_py, 'w') as fp:
fp.write(manage_py_contents)
self.addCleanup(safe_remove, test_manage_py)
@ -230,7 +237,7 @@ class DjangoAdminDefaultSettings(AdminScriptTestCase):
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=test_project.settings', 'admin_scripts']
out, err = self.run_django_admin(args)
self.assertNoOutput(err)
self.assertOutput(out, 'CREATE TABLE')
@ -238,7 +245,7 @@ class DjangoAdminDefaultSettings(AdminScriptTestCase):
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, 'test_project.settings')
self.assertNoOutput(err)
self.assertOutput(out, 'CREATE TABLE')
@ -265,7 +272,7 @@ class DjangoAdminDefaultSettings(AdminScriptTestCase):
def test_custom_command_with_settings(self):
"default: django-admin can execute user commands if settings are provided as argument"
args = ['noargs_command', '--settings=regressiontests.settings']
args = ['noargs_command', '--settings=test_project.settings']
out, err = self.run_django_admin(args)
self.assertNoOutput(err)
self.assertOutput(out, "EXECUTE:NoArgsCommand")
@ -273,7 +280,7 @@ class DjangoAdminDefaultSettings(AdminScriptTestCase):
def test_custom_command_with_environment(self):
"default: django-admin can execute user commands 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, 'test_project.settings')
self.assertNoOutput(err)
self.assertOutput(out, "EXECUTE:NoArgsCommand")
@ -282,7 +289,7 @@ class DjangoAdminFullPathDefaultSettings(AdminScriptTestCase):
contains the test application specified using a full path.
"""
def setUp(self):
self.write_settings('settings.py', ['django.contrib.auth', 'django.contrib.contenttypes', 'regressiontests.admin_scripts'])
self.write_settings('settings.py', ['django.contrib.auth', 'django.contrib.contenttypes', 'admin_scripts'])
def tearDown(self):
self.remove_settings('settings.py')
@ -296,7 +303,7 @@ class DjangoAdminFullPathDefaultSettings(AdminScriptTestCase):
def test_builtin_with_settings(self):
"fulldefault: django-admin builtin commands succeed if a settings file is provided"
args = ['sqlall', '--settings=regressiontests.settings', 'admin_scripts']
args = ['sqlall', '--settings=test_project.settings', 'admin_scripts']
out, err = self.run_django_admin(args)
self.assertNoOutput(err)
self.assertOutput(out, 'CREATE TABLE')
@ -304,7 +311,7 @@ class DjangoAdminFullPathDefaultSettings(AdminScriptTestCase):
def test_builtin_with_environment(self):
"fulldefault: django-admin builtin commands succeed if the environment contains settings"
args = ['sqlall', 'admin_scripts']
out, err = self.run_django_admin(args, 'regressiontests.settings')
out, err = self.run_django_admin(args, 'test_project.settings')
self.assertNoOutput(err)
self.assertOutput(out, 'CREATE TABLE')
@ -331,7 +338,7 @@ class DjangoAdminFullPathDefaultSettings(AdminScriptTestCase):
def test_custom_command_with_settings(self):
"fulldefault: django-admin can execute user commands if settings are provided as argument"
args = ['noargs_command', '--settings=regressiontests.settings']
args = ['noargs_command', '--settings=test_project.settings']
out, err = self.run_django_admin(args)
self.assertNoOutput(err)
self.assertOutput(out, "EXECUTE:NoArgsCommand")
@ -339,7 +346,7 @@ class DjangoAdminFullPathDefaultSettings(AdminScriptTestCase):
def test_custom_command_with_environment(self):
"fulldefault: django-admin can execute user commands 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, 'test_project.settings')
self.assertNoOutput(err)
self.assertOutput(out, "EXECUTE:NoArgsCommand")
@ -362,7 +369,7 @@ class DjangoAdminMinimalSettings(AdminScriptTestCase):
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=test_project.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')
@ -370,7 +377,7 @@ class DjangoAdminMinimalSettings(AdminScriptTestCase):
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, 'test_project.settings')
self.assertNoOutput(out)
self.assertOutput(err, 'App with label admin_scripts could not be found')
@ -397,7 +404,7 @@ class DjangoAdminMinimalSettings(AdminScriptTestCase):
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=test_project.settings']
out, err = self.run_django_admin(args)
self.assertNoOutput(out)
self.assertOutput(err, "Unknown command: 'noargs_command'")
@ -405,7 +412,7 @@ class DjangoAdminMinimalSettings(AdminScriptTestCase):
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, 'test_project.settings')
self.assertNoOutput(out)
self.assertOutput(err, "Unknown command: 'noargs_command'")
@ -428,7 +435,7 @@ class DjangoAdminAlternateSettings(AdminScriptTestCase):
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=test_project.alternate_settings', 'admin_scripts']
out, err = self.run_django_admin(args)
self.assertNoOutput(err)
self.assertOutput(out, 'CREATE TABLE')
@ -436,7 +443,7 @@ class DjangoAdminAlternateSettings(AdminScriptTestCase):
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, 'test_project.alternate_settings')
self.assertNoOutput(err)
self.assertOutput(out, 'CREATE TABLE')
@ -463,7 +470,7 @@ class DjangoAdminAlternateSettings(AdminScriptTestCase):
def test_custom_command_with_settings(self):
"alternate: django-admin can execute user commands if settings are provided as argument"
args = ['noargs_command', '--settings=regressiontests.alternate_settings']
args = ['noargs_command', '--settings=test_project.alternate_settings']
out, err = self.run_django_admin(args)
self.assertNoOutput(err)
self.assertOutput(out, "EXECUTE:NoArgsCommand")
@ -471,7 +478,7 @@ class DjangoAdminAlternateSettings(AdminScriptTestCase):
def test_custom_command_with_environment(self):
"alternate: django-admin can execute user commands 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, 'test_project.alternate_settings')
self.assertNoOutput(err)
self.assertOutput(out, "EXECUTE:NoArgsCommand")
@ -499,7 +506,7 @@ class DjangoAdminMultipleSettings(AdminScriptTestCase):
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=test_project.alternate_settings', 'admin_scripts']
out, err = self.run_django_admin(args)
self.assertNoOutput(err)
self.assertOutput(out, 'CREATE TABLE')
@ -507,7 +514,7 @@ class DjangoAdminMultipleSettings(AdminScriptTestCase):
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, 'test_project.alternate_settings')
self.assertNoOutput(err)
self.assertOutput(out, 'CREATE TABLE')
@ -533,7 +540,7 @@ class DjangoAdminMultipleSettings(AdminScriptTestCase):
def test_custom_command_with_settings(self):
"alternate: django-admin can execute user commands if settings are provided as argument"
args = ['noargs_command', '--settings=regressiontests.alternate_settings']
args = ['noargs_command', '--settings=test_project.alternate_settings']
out, err = self.run_django_admin(args)
self.assertNoOutput(err)
self.assertOutput(out, "EXECUTE:NoArgsCommand")
@ -541,7 +548,7 @@ class DjangoAdminMultipleSettings(AdminScriptTestCase):
def test_custom_command_with_environment(self):
"alternate: django-admin can execute user commands 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, 'test_project.alternate_settings')
self.assertNoOutput(err)
self.assertOutput(out, "EXECUTE:NoArgsCommand")
@ -562,17 +569,17 @@ class DjangoAdminSettingsDirectory(AdminScriptTestCase):
"directory: startapp creates the correct directory"
args = ['startapp', 'settings_test']
app_path = os.path.join(test_dir, 'settings_test')
out, err = self.run_django_admin(args, 'regressiontests.settings')
out, err = self.run_django_admin(args, 'test_project.settings')
self.addCleanup(shutil.rmtree, app_path)
self.assertNoOutput(err)
self.assertTrue(os.path.exists(app_path))
def test_setup_environ_custom_template(self):
"directory: startapp creates the correct directory with a custom template"
template_path = os.path.join(test_dir, 'admin_scripts', 'custom_templates', 'app_template')
template_path = os.path.join(custom_templates_dir, 'app_template')
args = ['startapp', '--template', template_path, 'custom_settings_test']
app_path = os.path.join(test_dir, 'custom_settings_test')
out, err = self.run_django_admin(args, 'regressiontests.settings')
out, err = self.run_django_admin(args, 'test_project.settings')
self.addCleanup(shutil.rmtree, app_path)
self.assertNoOutput(err)
self.assertTrue(os.path.exists(app_path))
@ -607,7 +614,7 @@ class DjangoAdminSettingsDirectory(AdminScriptTestCase):
def test_builtin_with_settings(self):
"directory: django-admin builtin commands succeed if settings are provided as argument"
args = ['sqlall', '--settings=regressiontests.settings', 'admin_scripts']
args = ['sqlall', '--settings=test_project.settings', 'admin_scripts']
out, err = self.run_django_admin(args)
self.assertNoOutput(err)
self.assertOutput(out, 'CREATE TABLE')
@ -615,7 +622,7 @@ class DjangoAdminSettingsDirectory(AdminScriptTestCase):
def test_builtin_with_environment(self):
"directory: 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, 'test_project.settings')
self.assertNoOutput(err)
self.assertOutput(out, 'CREATE TABLE')
@ -634,7 +641,7 @@ class ManageNoSettings(AdminScriptTestCase):
args = ['sqlall', 'admin_scripts']
out, err = self.run_manage(args)
self.assertNoOutput(out)
self.assertOutput(err, "Could not import settings 'regressiontests.settings'")
self.assertOutput(err, "Could not import settings 'test_project.settings'")
def test_builtin_with_bad_settings(self):
"no settings: manage.py builtin commands fail if settings file (from argument) doesn't exist"
@ -670,7 +677,7 @@ class ManageDefaultSettings(AdminScriptTestCase):
def test_builtin_with_settings(self):
"default: manage.py builtin commands succeed if settings are provided as argument"
args = ['sqlall', '--settings=regressiontests.settings', 'admin_scripts']
args = ['sqlall', '--settings=test_project.settings', 'admin_scripts']
out, err = self.run_manage(args)
self.assertNoOutput(err)
self.assertOutput(out, 'CREATE TABLE')
@ -678,7 +685,7 @@ class ManageDefaultSettings(AdminScriptTestCase):
def test_builtin_with_environment(self):
"default: manage.py builtin commands succeed if settings are provided in the environment"
args = ['sqlall', 'admin_scripts']
out, err = self.run_manage(args, 'regressiontests.settings')
out, err = self.run_manage(args, 'test_project.settings')
self.assertNoOutput(err)
self.assertOutput(out, 'CREATE TABLE')
@ -705,7 +712,7 @@ class ManageDefaultSettings(AdminScriptTestCase):
def test_custom_command_with_settings(self):
"default: manage.py can execute user commands when settings are provided as argument"
args = ['noargs_command', '--settings=regressiontests.settings']
args = ['noargs_command', '--settings=test_project.settings']
out, err = self.run_manage(args)
self.assertNoOutput(err)
self.assertOutput(out, "EXECUTE:NoArgsCommand")
@ -713,7 +720,7 @@ class ManageDefaultSettings(AdminScriptTestCase):
def test_custom_command_with_environment(self):
"default: manage.py can execute user commands when settings are provided in environment"
args = ['noargs_command']
out, err = self.run_manage(args, 'regressiontests.settings')
out, err = self.run_manage(args, 'test_project.settings')
self.assertNoOutput(err)
self.assertOutput(out, "EXECUTE:NoArgsCommand")
@ -723,7 +730,7 @@ class ManageFullPathDefaultSettings(AdminScriptTestCase):
contains the test application specified using a full path.
"""
def setUp(self):
self.write_settings('settings.py', ['django.contrib.auth', 'django.contrib.contenttypes', 'regressiontests.admin_scripts'])
self.write_settings('settings.py', ['django.contrib.auth', 'django.contrib.contenttypes', 'admin_scripts'])
def tearDown(self):
self.remove_settings('settings.py')
@ -737,7 +744,7 @@ class ManageFullPathDefaultSettings(AdminScriptTestCase):
def test_builtin_with_settings(self):
"fulldefault: manage.py builtin commands succeed if settings are provided as argument"
args = ['sqlall', '--settings=regressiontests.settings', 'admin_scripts']
args = ['sqlall', '--settings=test_project.settings', 'admin_scripts']
out, err = self.run_manage(args)
self.assertNoOutput(err)
self.assertOutput(out, 'CREATE TABLE')
@ -745,7 +752,7 @@ class ManageFullPathDefaultSettings(AdminScriptTestCase):
def test_builtin_with_environment(self):
"fulldefault: manage.py builtin commands succeed if settings are provided in the environment"
args = ['sqlall', 'admin_scripts']
out, err = self.run_manage(args, 'regressiontests.settings')
out, err = self.run_manage(args, 'test_project.settings')
self.assertNoOutput(err)
self.assertOutput(out, 'CREATE TABLE')
@ -772,7 +779,7 @@ class ManageFullPathDefaultSettings(AdminScriptTestCase):
def test_custom_command_with_settings(self):
"fulldefault: manage.py can execute user commands when settings are provided as argument"
args = ['noargs_command', '--settings=regressiontests.settings']
args = ['noargs_command', '--settings=test_project.settings']
out, err = self.run_manage(args)
self.assertNoOutput(err)
self.assertOutput(out, "EXECUTE:NoArgsCommand")
@ -780,7 +787,7 @@ class ManageFullPathDefaultSettings(AdminScriptTestCase):
def test_custom_command_with_environment(self):
"fulldefault: manage.py can execute user commands when settings are provided in environment"
args = ['noargs_command']
out, err = self.run_manage(args, 'regressiontests.settings')
out, err = self.run_manage(args, 'test_project.settings')
self.assertNoOutput(err)
self.assertOutput(out, "EXECUTE:NoArgsCommand")
@ -803,7 +810,7 @@ class ManageMinimalSettings(AdminScriptTestCase):
def test_builtin_with_settings(self):
"minimal: manage.py builtin commands fail if settings are provided as argument"
args = ['sqlall', '--settings=regressiontests.settings', 'admin_scripts']
args = ['sqlall', '--settings=test_project.settings', 'admin_scripts']
out, err = self.run_manage(args)
self.assertNoOutput(out)
self.assertOutput(err, 'App with label admin_scripts could not be found')
@ -811,7 +818,7 @@ class ManageMinimalSettings(AdminScriptTestCase):
def test_builtin_with_environment(self):
"minimal: manage.py builtin commands fail if settings are provided in the environment"
args = ['sqlall', 'admin_scripts']
out, err = self.run_manage(args, 'regressiontests.settings')
out, err = self.run_manage(args, 'test_project.settings')
self.assertNoOutput(out)
self.assertOutput(err, 'App with label admin_scripts could not be found')
@ -838,7 +845,7 @@ class ManageMinimalSettings(AdminScriptTestCase):
def test_custom_command_with_settings(self):
"minimal: manage.py can't execute user commands, even if settings are provided as argument"
args = ['noargs_command', '--settings=regressiontests.settings']
args = ['noargs_command', '--settings=test_project.settings']
out, err = self.run_manage(args)
self.assertNoOutput(out)
self.assertOutput(err, "Unknown command: 'noargs_command'")
@ -846,7 +853,7 @@ class ManageMinimalSettings(AdminScriptTestCase):
def test_custom_command_with_environment(self):
"minimal: manage.py can't execute user commands, even if settings are provided in environment"
args = ['noargs_command']
out, err = self.run_manage(args, 'regressiontests.settings')
out, err = self.run_manage(args, 'test_project.settings')
self.assertNoOutput(out)
self.assertOutput(err, "Unknown command: 'noargs_command'")
@ -865,7 +872,7 @@ class ManageAlternateSettings(AdminScriptTestCase):
args = ['sqlall', 'admin_scripts']
out, err = self.run_manage(args)
self.assertNoOutput(out)
self.assertOutput(err, "Could not import settings 'regressiontests.settings'")
self.assertOutput(err, "Could not import settings 'test_project.settings'")
def test_builtin_with_settings(self):
"alternate: manage.py builtin commands work with settings provided as argument"
@ -904,7 +911,7 @@ class ManageAlternateSettings(AdminScriptTestCase):
args = ['noargs_command']
out, err = self.run_manage(args)
self.assertNoOutput(out)
self.assertOutput(err, "Could not import settings 'regressiontests.settings'")
self.assertOutput(err, "Could not import settings 'test_project.settings'")
def test_custom_command_with_settings(self):
"alternate: manage.py can execute user commands if settings are provided as argument"
@ -1007,7 +1014,7 @@ class ManageSettingsWithImportError(AdminScriptTestCase):
else:
settings_file_path = os.path.join(test_dir, filename)
with open(settings_file_path, 'w') as settings_file:
settings_file.write('# Settings file automatically generated by regressiontests.admin_scripts test case\n')
settings_file.write('# Settings file automatically generated by admin_scripts test case\n')
settings_file.write('# The next line will cause an import error:\nimport foo42bar\n')
def test_builtin_command(self):
@ -1104,13 +1111,13 @@ class ManageTestCommand(AdminScriptTestCase):
address_predefined = 'DJANGO_LIVE_TEST_SERVER_ADDRESS' in os.environ
old_address = os.environ.get('DJANGO_LIVE_TEST_SERVER_ADDRESS')
self.cmd.handle(verbosity=0, testrunner='regressiontests.admin_scripts.tests.CustomTestRunner')
self.cmd.handle(verbosity=0, testrunner='admin_scripts.tests.CustomTestRunner')
# Original state hasn't changed
self.assertEqual('DJANGO_LIVE_TEST_SERVER_ADDRESS' in os.environ, address_predefined)
self.assertEqual(os.environ.get('DJANGO_LIVE_TEST_SERVER_ADDRESS'), old_address)
self.cmd.handle(verbosity=0, testrunner='regressiontests.admin_scripts.tests.CustomTestRunner',
self.cmd.handle(verbosity=0, testrunner='admin_scripts.tests.CustomTestRunner',
liveserver='blah')
# Variable was correctly set
@ -1485,7 +1492,7 @@ class StartProject(LiveServerTestCase, AdminScriptTestCase):
def test_custom_project_template(self):
"Make sure the startproject management command is able to use a different project template"
template_path = os.path.join(test_dir, 'admin_scripts', 'custom_templates', 'project_template')
template_path = os.path.join(custom_templates_dir, 'project_template')
args = ['startproject', '--template', template_path, 'customtestproject']
testproject_dir = os.path.join(test_dir, 'customtestproject')
self.addCleanup(shutil.rmtree, testproject_dir, True)
@ -1497,7 +1504,7 @@ class StartProject(LiveServerTestCase, AdminScriptTestCase):
def test_template_dir_with_trailing_slash(self):
"Ticket 17475: Template dir passed has a trailing path separator"
template_path = os.path.join(test_dir, 'admin_scripts', 'custom_templates', 'project_template' + os.sep)
template_path = os.path.join(custom_templates_dir, 'project_template' + os.sep)
args = ['startproject', '--template', template_path, 'customtestproject']
testproject_dir = os.path.join(test_dir, 'customtestproject')
self.addCleanup(shutil.rmtree, testproject_dir, True)
@ -1509,7 +1516,7 @@ class StartProject(LiveServerTestCase, AdminScriptTestCase):
def test_custom_project_template_from_tarball_by_path(self):
"Make sure the startproject management command is able to use a different project template from a tarball"
template_path = os.path.join(test_dir, 'admin_scripts', 'custom_templates', 'project_template.tgz')
template_path = os.path.join(custom_templates_dir, 'project_template.tgz')
args = ['startproject', '--template', template_path, 'tarballtestproject']
testproject_dir = os.path.join(test_dir, 'tarballtestproject')
self.addCleanup(shutil.rmtree, testproject_dir, True)
@ -1521,7 +1528,7 @@ class StartProject(LiveServerTestCase, AdminScriptTestCase):
def test_custom_project_template_from_tarball_to_alternative_location(self):
"Startproject can use a project template from a tarball and create it in a specified location"
template_path = os.path.join(test_dir, 'admin_scripts', 'custom_templates', 'project_template.tgz')
template_path = os.path.join(custom_templates_dir, 'project_template.tgz')
args = ['startproject', '--template', template_path, 'tarballtestproject', 'altlocation']
testproject_dir = os.path.join(test_dir, 'altlocation')
os.mkdir(testproject_dir)
@ -1560,7 +1567,7 @@ class StartProject(LiveServerTestCase, AdminScriptTestCase):
def test_file_without_extension(self):
"Make sure the startproject management command is able to render custom files"
template_path = os.path.join(test_dir, 'admin_scripts', 'custom_templates', 'project_template')
template_path = os.path.join(custom_templates_dir, 'project_template')
args = ['startproject', '--template', template_path, 'customtestproject', '-e', 'txt', '-n', 'Procfile']
testproject_dir = os.path.join(test_dir, 'customtestproject')
self.addCleanup(shutil.rmtree, testproject_dir, True)
@ -1578,7 +1585,7 @@ class StartProject(LiveServerTestCase, AdminScriptTestCase):
def test_custom_project_template_context_variables(self):
"Make sure template context variables are rendered with proper values"
template_path = os.path.join(test_dir, 'admin_scripts', 'custom_templates', 'project_template')
template_path = os.path.join(custom_templates_dir, 'project_template')
args = ['startproject', '--template', template_path, 'another_project', 'project_dir']
testproject_dir = os.path.join(test_dir, 'project_dir')
os.mkdir(testproject_dir)
@ -1596,7 +1603,7 @@ class StartProject(LiveServerTestCase, AdminScriptTestCase):
# We're using a custom command so we need the alternate settings
self.write_settings('alternate_settings.py')
self.addCleanup(self.remove_settings, 'alternate_settings.py')
template_path = os.path.join(test_dir, 'admin_scripts', 'custom_templates', 'project_template')
template_path = os.path.join(custom_templates_dir, 'project_template')
args = ['custom_startproject', '--template', template_path, 'another_project', 'project_dir', '--extra', '<&>', '--settings=alternate_settings']
testproject_dir = os.path.join(test_dir, 'project_dir')
os.mkdir(testproject_dir)
@ -1613,7 +1620,7 @@ class StartProject(LiveServerTestCase, AdminScriptTestCase):
Make sure an exception is raised when the provided
destination directory doesn't exist
"""
template_path = os.path.join(test_dir, 'admin_scripts', 'custom_templates', 'project_template')
template_path = os.path.join(custom_templates_dir, 'project_template')
args = ['startproject', '--template', template_path, 'yet_another_project', 'project_dir2']
testproject_dir = os.path.join(test_dir, 'project_dir2')
out, err = self.run_django_admin(args)
@ -1623,7 +1630,7 @@ class StartProject(LiveServerTestCase, AdminScriptTestCase):
def test_custom_project_template_with_non_ascii_templates(self):
"Ticket 18091: Make sure the startproject management command is able to render templates with non-ASCII content"
template_path = os.path.join(test_dir, 'admin_scripts', 'custom_templates', 'project_template')
template_path = os.path.join(custom_templates_dir, 'project_template')
args = ['startproject', '--template', template_path, '--extension=txt', 'customtestproject']
testproject_dir = os.path.join(test_dir, 'customtestproject')
self.addCleanup(shutil.rmtree, testproject_dir, True)