From 89f40e36246100df6a11316c31a76712ebc6c501 Mon Sep 17 00:00:00 2001 From: Florian Apolloner Date: Tue, 26 Feb 2013 09:53:47 +0100 Subject: Merged regressiontests and modeltests into the test root. --- tests/admin_scripts/tests.py | 1649 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 1649 insertions(+) create mode 100644 tests/admin_scripts/tests.py (limited to 'tests/admin_scripts/tests.py') diff --git a/tests/admin_scripts/tests.py b/tests/admin_scripts/tests.py new file mode 100644 index 0000000000..921108600e --- /dev/null +++ b/tests/admin_scripts/tests.py @@ -0,0 +1,1649 @@ +# -*- coding: utf-8 -*- +""" +A series of tests to establish that the command-line managment tools work as +advertised - especially with regards to the handling of the DJANGO_SETTINGS_MODULE +and default settings.py files. +""" +from __future__ import unicode_literals + +import os +import re +import shutil +import socket +import subprocess +import sys +import codecs + +from django import conf, bin, get_version +from django.conf import settings +from django.core.management import BaseCommand +from django.db import connection +from django.test.simple import DjangoTestSuiteRunner +from django.utils import unittest +from django.utils.encoding import force_str, force_text +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__))) + +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) + settings_file_path = os.path.join(settings_dir, '__init__.py') + 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') + exports = [ + 'DATABASES', + 'ROOT_URLCONF', + 'SECRET_KEY', + ] + for s in exports: + if hasattr(settings, s): + o = getattr(settings, s) + if not isinstance(o, dict): + o = "'%s'" % o + settings_file.write("%s = %s\n" % (s, o)) + + if apps is None: + apps = ['django.contrib.auth', 'django.contrib.contenttypes', 'regressiontests.admin_scripts'] + + settings_file.write("INSTALLED_APPS = %s\n" % apps) + + if sdict: + for k, v in sdict.items(): + settings_file.write("%s = %s\n" % (k, v)) + + def remove_settings(self, filename, is_dir=False): + full_name = os.path.join(test_dir, filename) + if is_dir: + shutil.rmtree(full_name) + else: + os.remove(full_name) + + # Also try to remove the compiled file; if it exists, it could + # mess up later tests that depend upon the .py file not existing + try: + if sys.platform.startswith('java'): + # Jython produces module$py.class files + os.remove(re.sub(r'\.py$', '$py.class', full_name)) + else: + # CPython produces module.pyc files + os.remove(full_name + 'c') + except OSError: + pass + # Also remove a __pycache__ directory, if it exists + cache_name = os.path.join(test_dir, '__pycache__') + if os.path.isdir(cache_name): + shutil.rmtree(cache_name) + + def _ext_backend_paths(self): + """ + Returns the paths for any external backend packages. + """ + paths = [] + first_package_re = re.compile(r'(^[^\.]+)\.') + for backend in settings.DATABASES.values(): + result = first_package_re.findall(backend['ENGINE']) + 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) + base_dir = os.path.dirname(project_dir) + ext_backend_base_dirs = self._ext_backend_paths() + + # Remember the old environment + old_django_settings_module = os.environ.get('DJANGO_SETTINGS_MODULE', None) + if sys.platform.startswith('java'): + python_path_var_name = 'JYTHONPATH' + else: + python_path_var_name = 'PYTHONPATH' + + old_python_path = os.environ.get(python_path_var_name, None) + old_cwd = os.getcwd() + + # Set the test environment + if settings_file: + 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.extend(ext_backend_base_dirs) + os.environ[python_path_var_name] = os.pathsep.join(python_path) + + # Move to the test directory and run + os.chdir(test_dir) + 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 + if old_python_path: + os.environ[python_path_var_name] = old_python_path + # Move back to the old working directory + os.chdir(old_cwd) + + return out, err + + def run_django_admin(self, args, settings_file=None): + bin_dir = os.path.abspath(os.path.dirname(upath(bin.__file__))) + return self.run_test(os.path.join(bin_dir, 'django-admin.py'), args, settings_file) + + def run_manage(self, args, settings_file=None): + def safe_remove(path): + try: + os.remove(path) + except OSError: + pass + + conf_dir = os.path.dirname(upath(conf.__file__)) + template_manage_py = os.path.join(conf_dir, 'project_template', 'manage.py') + + test_manage_py = os.path.join(test_dir, 'manage.py') + shutil.copyfile(template_manage_py, test_manage_py) + + with open(test_manage_py, 'r') as fp: + manage_py_contents = fp.read() + manage_py_contents = manage_py_contents.replace( + "{{ project_name }}", "regressiontests") + with open(test_manage_py, 'w') as fp: + fp.write(manage_py_contents) + self.addCleanup(safe_remove, test_manage_py) + + return self.run_test('./manage.py', args, settings_file) + + def assertNoOutput(self, stream): + "Utility assertion: assert that the given stream is empty" + self.assertEqual(len(stream), 0, "Stream should be empty: actually contains '%s'" % stream) + + def assertOutput(self, stream, msg): + "Utility assertion: assert that the given message exists in the output" + stream = force_text(stream) + self.assertTrue(msg in stream, "'%s' does not match actual output text '%s'" % (msg, stream)) + + def assertNotInOutput(self, stream, msg): + "Utility assertion: assert that the given message doesn't exist in the output" + stream = force_text(stream) + self.assertFalse(msg in stream, "'%s' matches actual output text '%s'" % (msg, stream)) + +########################################################################## +# DJANGO ADMIN TESTS +# This first series of test classes checks the environment processing +# of the django-admin.py script +########################################################################## + + +class DjangoAdminNoSettings(AdminScriptTestCase): + "A series of tests for django-admin.py when there is no settings.py file." + + def test_builtin_command(self): + "no settings: django-admin builtin commands fail with an error when no settings provided" + args = ['sqlall', 'admin_scripts'] + out, err = self.run_django_admin(args) + self.assertNoOutput(out) + self.assertOutput(err, 'settings are not configured') + + 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=bad_settings', 'admin_scripts'] + out, err = self.run_django_admin(args) + self.assertNoOutput(out) + 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, 'bad_settings') + self.assertNoOutput(out) + self.assertOutput(err, "Could not import settings 'bad_settings'") + + +class DjangoAdminDefaultSettings(AdminScriptTestCase): + """A series of tests for django-admin.py when using a settings.py file that + contains the test application. + """ + def setUp(self): + self.write_settings('settings.py') + + def tearDown(self): + self.remove_settings('settings.py') + + def test_builtin_command(self): + "default: django-admin builtin commands fail with an error when no settings provided" + args = ['sqlall', 'admin_scripts'] + out, err = self.run_django_admin(args) + self.assertNoOutput(out) + self.assertOutput(err, 'settings are not configured') + + 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'] + out, err = self.run_django_admin(args) + self.assertNoOutput(err) + self.assertOutput(out, 'CREATE TABLE') + + 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') + 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=bad_settings', 'admin_scripts'] + out, err = self.run_django_admin(args) + self.assertNoOutput(out) + 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, 'bad_settings') + self.assertNoOutput(out) + self.assertOutput(err, "Could not import settings 'bad_settings'") + + def test_custom_command(self): + "default: django-admin can't execute user commands if it isn't provided settings" + args = ['noargs_command'] + out, err = self.run_django_admin(args) + self.assertNoOutput(out) + self.assertOutput(err, "Unknown command: 'noargs_command'") + + 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'] + out, err = self.run_django_admin(args) + self.assertNoOutput(err) + self.assertOutput(out, "EXECUTE:NoArgsCommand") + + 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') + self.assertNoOutput(err) + self.assertOutput(out, "EXECUTE:NoArgsCommand") + +class DjangoAdminFullPathDefaultSettings(AdminScriptTestCase): + """A series of tests for django-admin.py when using a settings.py file that + 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']) + + def tearDown(self): + self.remove_settings('settings.py') + + def test_builtin_command(self): + "fulldefault: django-admin builtin commands fail with an error when no settings provided" + args = ['sqlall', 'admin_scripts'] + out, err = self.run_django_admin(args) + self.assertNoOutput(out) + self.assertOutput(err, 'settings are not configured') + + 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'] + out, err = self.run_django_admin(args) + self.assertNoOutput(err) + self.assertOutput(out, 'CREATE TABLE') + + 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') + self.assertNoOutput(err) + self.assertOutput(out, 'CREATE TABLE') + + def test_builtin_with_bad_settings(self): + "fulldefault: django-admin builtin commands fail if settings file (from argument) doesn't exist" + args = ['sqlall', '--settings=bad_settings', 'admin_scripts'] + out, err = self.run_django_admin(args) + self.assertNoOutput(out) + self.assertOutput(err, "Could not import settings 'bad_settings'") + + def test_builtin_with_bad_environment(self): + "fulldefault: django-admin builtin commands fail if settings file (from environment) doesn't exist" + args = ['sqlall', 'admin_scripts'] + out, err = self.run_django_admin(args, 'bad_settings') + self.assertNoOutput(out) + self.assertOutput(err, "Could not import settings 'bad_settings'") + + def test_custom_command(self): + "fulldefault: django-admin can't execute user commands unless settings are provided" + args = ['noargs_command'] + out, err = self.run_django_admin(args) + self.assertNoOutput(out) + self.assertOutput(err, "Unknown command: 'noargs_command'") + + 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'] + out, err = self.run_django_admin(args) + self.assertNoOutput(err) + self.assertOutput(out, "EXECUTE:NoArgsCommand") + + 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') + self.assertNoOutput(err) + self.assertOutput(out, "EXECUTE:NoArgsCommand") + +class DjangoAdminMinimalSettings(AdminScriptTestCase): + """A series of tests for django-admin.py when using a settings.py file that + doesn't contain the test application. + """ + def setUp(self): + self.write_settings('settings.py', apps=['django.contrib.auth', 'django.contrib.contenttypes']) + + def tearDown(self): + self.remove_settings('settings.py') + + def test_builtin_command(self): + "minimal: django-admin builtin commands fail with an error when no settings provided" + args = ['sqlall', 'admin_scripts'] + out, err = self.run_django_admin(args) + self.assertNoOutput(out) + self.assertOutput(err, 'settings are not configured') + + 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'] + out, err = self.run_django_admin(args) + self.assertNoOutput(out) + self.assertOutput(err, 'App with label admin_scripts could not be found') + + 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') + 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=bad_settings', 'admin_scripts'] + out, err = self.run_django_admin(args) + self.assertNoOutput(out) + 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, 'bad_settings') + self.assertNoOutput(out) + self.assertOutput(err, "Could not import settings 'bad_settings'") + + def test_custom_command(self): + "minimal: django-admin can't execute user commands unless settings are provided" + args = ['noargs_command'] + out, err = self.run_django_admin(args) + self.assertNoOutput(out) + self.assertOutput(err, "Unknown command: 'noargs_command'") + + 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'] + out, err = self.run_django_admin(args) + self.assertNoOutput(out) + self.assertOutput(err, "Unknown command: 'noargs_command'") + + 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') + self.assertNoOutput(out) + self.assertOutput(err, "Unknown command: 'noargs_command'") + +class DjangoAdminAlternateSettings(AdminScriptTestCase): + """A series of tests for django-admin.py when using a settings file + with a name other than 'settings.py'. + """ + def setUp(self): + self.write_settings('alternate_settings.py') + + def tearDown(self): + self.remove_settings('alternate_settings.py') + + def test_builtin_command(self): + "alternate: django-admin builtin commands fail with an error when no settings provided" + args = ['sqlall', 'admin_scripts'] + out, err = self.run_django_admin(args) + self.assertNoOutput(out) + self.assertOutput(err, 'settings are not configured') + + 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'] + out, err = self.run_django_admin(args) + self.assertNoOutput(err) + self.assertOutput(out, 'CREATE TABLE') + + 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') + 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=bad_settings', 'admin_scripts'] + out, err = self.run_django_admin(args) + self.assertNoOutput(out) + 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, 'bad_settings') + self.assertNoOutput(out) + self.assertOutput(err, "Could not import settings 'bad_settings'") + + def test_custom_command(self): + "alternate: django-admin can't execute user commands unless settings are provided" + args = ['noargs_command'] + out, err = self.run_django_admin(args) + self.assertNoOutput(out) + self.assertOutput(err, "Unknown command: 'noargs_command'") + + 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'] + out, err = self.run_django_admin(args) + self.assertNoOutput(err) + self.assertOutput(out, "EXECUTE:NoArgsCommand") + + 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') + self.assertNoOutput(err) + self.assertOutput(out, "EXECUTE:NoArgsCommand") + + +class DjangoAdminMultipleSettings(AdminScriptTestCase): + """A series of tests for django-admin.py when multiple settings files + (including the default 'settings.py') are available. The default settings + file is insufficient for performing the operations described, so the + alternate settings must be used by the running script. + """ + def setUp(self): + self.write_settings('settings.py', apps=['django.contrib.auth', 'django.contrib.contenttypes']) + self.write_settings('alternate_settings.py') + + def tearDown(self): + self.remove_settings('settings.py') + self.remove_settings('alternate_settings.py') + + def test_builtin_command(self): + "alternate: django-admin builtin commands fail with an error when no settings provided" + args = ['sqlall', 'admin_scripts'] + out, err = self.run_django_admin(args) + self.assertNoOutput(out) + self.assertOutput(err, 'settings are not configured') + + 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'] + out, err = self.run_django_admin(args) + self.assertNoOutput(err) + self.assertOutput(out, 'CREATE TABLE') + + 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') + 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=bad_settings', 'admin_scripts'] + out, err = self.run_django_admin(args) + 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, 'bad_settings') + self.assertNoOutput(out) + self.assertOutput(err, "Could not import settings 'bad_settings'") + + def test_custom_command(self): + "alternate: django-admin can't execute user commands unless settings are provided" + args = ['noargs_command'] + out, err = self.run_django_admin(args) + self.assertNoOutput(out) + self.assertOutput(err, "Unknown command: 'noargs_command'") + + 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'] + out, err = self.run_django_admin(args) + self.assertNoOutput(err) + self.assertOutput(out, "EXECUTE:NoArgsCommand") + + 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') + self.assertNoOutput(err) + self.assertOutput(out, "EXECUTE:NoArgsCommand") + + +class DjangoAdminSettingsDirectory(AdminScriptTestCase): + """ + A series of tests for django-admin.py when the settings file is in a + directory. (see #9751). + """ + + def setUp(self): + self.write_settings('settings', is_dir=True) + + def tearDown(self): + self.remove_settings('settings', is_dir=True) + + def test_setup_environ(self): + "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') + 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') + 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') + self.addCleanup(shutil.rmtree, app_path) + self.assertNoOutput(err) + self.assertTrue(os.path.exists(app_path)) + self.assertTrue(os.path.exists(os.path.join(app_path, 'api.py'))) + + def test_builtin_command(self): + "directory: django-admin builtin commands fail with an error when no settings provided" + args = ['sqlall', 'admin_scripts'] + out, err = self.run_django_admin(args) + self.assertNoOutput(out) + self.assertOutput(err, 'settings are not configured') + + def test_builtin_with_bad_settings(self): + "directory: django-admin builtin commands fail if settings file (from argument) doesn't exist" + args = ['sqlall', '--settings=bad_settings', 'admin_scripts'] + out, err = self.run_django_admin(args) + self.assertOutput(err, "Could not import settings 'bad_settings'") + + def test_builtin_with_bad_environment(self): + "directory: django-admin builtin commands fail if settings file (from environment) doesn't exist" + args = ['sqlall', 'admin_scripts'] + out, err = self.run_django_admin(args, 'bad_settings') + self.assertNoOutput(out) + self.assertOutput(err, "Could not import settings 'bad_settings'") + + def test_custom_command(self): + "directory: django-admin can't execute user commands unless settings are provided" + args = ['noargs_command'] + out, err = self.run_django_admin(args) + self.assertNoOutput(out) + self.assertOutput(err, "Unknown command: 'noargs_command'") + + 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'] + out, err = self.run_django_admin(args) + self.assertNoOutput(err) + self.assertOutput(out, 'CREATE TABLE') + + 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') + self.assertNoOutput(err) + self.assertOutput(out, 'CREATE TABLE') + + +########################################################################## +# MANAGE.PY TESTS +# This next series of test classes checks the environment processing +# of the generated manage.py script +########################################################################## + +class ManageNoSettings(AdminScriptTestCase): + "A series of tests for manage.py when there is no settings.py file." + + def test_builtin_command(self): + "no settings: manage.py builtin commands fail with an error when no settings provided" + args = ['sqlall', 'admin_scripts'] + out, err = self.run_manage(args) + self.assertNoOutput(out) + self.assertOutput(err, "Could not import settings 'regressiontests.settings'") + + def test_builtin_with_bad_settings(self): + "no settings: manage.py builtin commands fail if settings file (from argument) doesn't exist" + args = ['sqlall', '--settings=bad_settings', 'admin_scripts'] + out, err = self.run_manage(args) + self.assertNoOutput(out) + self.assertOutput(err, "Could not import settings 'bad_settings'") + + def test_builtin_with_bad_environment(self): + "no settings: manage.py builtin commands fail if settings file (from environment) doesn't exist" + args = ['sqlall', 'admin_scripts'] + out, err = self.run_manage(args, 'bad_settings') + self.assertNoOutput(out) + self.assertOutput(err, "Could not import settings 'bad_settings'") + + +class ManageDefaultSettings(AdminScriptTestCase): + """A series of tests for manage.py when using a settings.py file that + contains the test application. + """ + def setUp(self): + self.write_settings('settings.py') + + def tearDown(self): + self.remove_settings('settings.py') + + def test_builtin_command(self): + "default: manage.py builtin commands succeed when default settings are appropriate" + args = ['sqlall', 'admin_scripts'] + out, err = self.run_manage(args) + self.assertNoOutput(err) + self.assertOutput(out, 'CREATE TABLE') + + 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'] + out, err = self.run_manage(args) + self.assertNoOutput(err) + self.assertOutput(out, 'CREATE TABLE') + + 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') + self.assertNoOutput(err) + self.assertOutput(out, 'CREATE TABLE') + + def test_builtin_with_bad_settings(self): + "default: manage.py builtin commands succeed if settings file (from argument) doesn't exist" + args = ['sqlall', '--settings=bad_settings', 'admin_scripts'] + out, err = self.run_manage(args) + self.assertNoOutput(out) + self.assertOutput(err, "Could not import settings 'bad_settings'") + + def test_builtin_with_bad_environment(self): + "default: manage.py builtin commands fail if settings file (from environment) doesn't exist" + args = ['sqlall', 'admin_scripts'] + out, err = self.run_manage(args, 'bad_settings') + self.assertNoOutput(out) + self.assertOutput(err, "Could not import settings 'bad_settings'") + + def test_custom_command(self): + "default: manage.py can execute user commands when default settings are appropriate" + args = ['noargs_command'] + out, err = self.run_manage(args) + self.assertNoOutput(err) + self.assertOutput(out, "EXECUTE:NoArgsCommand") + + 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'] + out, err = self.run_manage(args) + self.assertNoOutput(err) + self.assertOutput(out, "EXECUTE:NoArgsCommand") + + 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') + self.assertNoOutput(err) + self.assertOutput(out, "EXECUTE:NoArgsCommand") + + +class ManageFullPathDefaultSettings(AdminScriptTestCase): + """A series of tests for manage.py when using a settings.py file that + 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']) + + def tearDown(self): + self.remove_settings('settings.py') + + def test_builtin_command(self): + "fulldefault: manage.py builtin commands succeed when default settings are appropriate" + args = ['sqlall', 'admin_scripts'] + out, err = self.run_manage(args) + self.assertNoOutput(err) + self.assertOutput(out, 'CREATE TABLE') + + 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'] + out, err = self.run_manage(args) + self.assertNoOutput(err) + self.assertOutput(out, 'CREATE TABLE') + + 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') + self.assertNoOutput(err) + self.assertOutput(out, 'CREATE TABLE') + + def test_builtin_with_bad_settings(self): + "fulldefault: manage.py builtin commands succeed if settings file (from argument) doesn't exist" + args = ['sqlall', '--settings=bad_settings', 'admin_scripts'] + out, err = self.run_manage(args) + self.assertNoOutput(out) + self.assertOutput(err, "Could not import settings 'bad_settings'") + + def test_builtin_with_bad_environment(self): + "fulldefault: manage.py builtin commands fail if settings file (from environment) doesn't exist" + args = ['sqlall', 'admin_scripts'] + out, err = self.run_manage(args, 'bad_settings') + self.assertNoOutput(out) + self.assertOutput(err, "Could not import settings 'bad_settings'") + + def test_custom_command(self): + "fulldefault: manage.py can execute user commands when default settings are appropriate" + args = ['noargs_command'] + out, err = self.run_manage(args) + self.assertNoOutput(err) + self.assertOutput(out, "EXECUTE:NoArgsCommand") + + 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'] + out, err = self.run_manage(args) + self.assertNoOutput(err) + self.assertOutput(out, "EXECUTE:NoArgsCommand") + + 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') + self.assertNoOutput(err) + self.assertOutput(out, "EXECUTE:NoArgsCommand") + +class ManageMinimalSettings(AdminScriptTestCase): + """A series of tests for manage.py when using a settings.py file that + doesn't contain the test application. + """ + def setUp(self): + self.write_settings('settings.py', apps=['django.contrib.auth', 'django.contrib.contenttypes']) + + def tearDown(self): + self.remove_settings('settings.py') + + def test_builtin_command(self): + "minimal: manage.py builtin commands fail with an error when no settings provided" + args = ['sqlall', 'admin_scripts'] + out, err = self.run_manage(args) + self.assertNoOutput(out) + self.assertOutput(err, 'App with label admin_scripts could not be found') + + 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'] + out, err = self.run_manage(args) + self.assertNoOutput(out) + self.assertOutput(err, 'App with label admin_scripts could not be found') + + 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') + self.assertNoOutput(out) + self.assertOutput(err, 'App with label admin_scripts could not be found') + + def test_builtin_with_bad_settings(self): + "minimal: manage.py builtin commands fail if settings file (from argument) doesn't exist" + args = ['sqlall', '--settings=bad_settings', 'admin_scripts'] + out, err = self.run_manage(args) + self.assertNoOutput(out) + self.assertOutput(err, "Could not import settings 'bad_settings'") + + def test_builtin_with_bad_environment(self): + "minimal: manage.py builtin commands fail if settings file (from environment) doesn't exist" + args = ['sqlall', 'admin_scripts'] + out, err = self.run_manage(args, 'bad_settings') + self.assertNoOutput(out) + self.assertOutput(err, "Could not import settings 'bad_settings'") + + def test_custom_command(self): + "minimal: manage.py can't execute user commands without appropriate settings" + args = ['noargs_command'] + out, err = self.run_manage(args) + self.assertNoOutput(out) + self.assertOutput(err, "Unknown command: 'noargs_command'") + + 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'] + out, err = self.run_manage(args) + self.assertNoOutput(out) + self.assertOutput(err, "Unknown command: 'noargs_command'") + + 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') + self.assertNoOutput(out) + self.assertOutput(err, "Unknown command: 'noargs_command'") + +class ManageAlternateSettings(AdminScriptTestCase): + """A series of tests for manage.py when using a settings file + with a name other than 'settings.py'. + """ + def setUp(self): + self.write_settings('alternate_settings.py') + + def tearDown(self): + self.remove_settings('alternate_settings.py') + + def test_builtin_command(self): + "alternate: manage.py builtin commands fail with an error when no default settings provided" + args = ['sqlall', 'admin_scripts'] + out, err = self.run_manage(args) + self.assertNoOutput(out) + self.assertOutput(err, "Could not import settings 'regressiontests.settings'") + + def test_builtin_with_settings(self): + "alternate: manage.py builtin commands work with settings provided as argument" + args = ['sqlall', '--settings=alternate_settings', 'admin_scripts'] + out, err = self.run_manage(args) + expected = ('create table %s' + % connection.ops.quote_name('admin_scripts_article')) + self.assertTrue(expected.lower() in out.lower()) + self.assertNoOutput(err) + + def test_builtin_with_environment(self): + "alternate: manage.py builtin commands work if settings are provided in the environment" + args = ['sqlall', 'admin_scripts'] + out, err = self.run_manage(args, 'alternate_settings') + expected = ('create table %s' + % connection.ops.quote_name('admin_scripts_article')) + self.assertTrue(expected.lower() in out.lower()) + self.assertNoOutput(err) + + def test_builtin_with_bad_settings(self): + "alternate: manage.py builtin commands fail if settings file (from argument) doesn't exist" + args = ['sqlall', '--settings=bad_settings', 'admin_scripts'] + out, err = self.run_manage(args) + self.assertNoOutput(out) + self.assertOutput(err, "Could not import settings 'bad_settings'") + + def test_builtin_with_bad_environment(self): + "alternate: manage.py builtin commands fail if settings file (from environment) doesn't exist" + args = ['sqlall', 'admin_scripts'] + out, err = self.run_manage(args, 'bad_settings') + self.assertNoOutput(out) + self.assertOutput(err, "Could not import settings 'bad_settings'") + + def test_custom_command(self): + "alternate: manage.py can't execute user commands without settings" + args = ['noargs_command'] + out, err = self.run_manage(args) + self.assertNoOutput(out) + self.assertOutput(err, "Could not import settings 'regressiontests.settings'") + + def test_custom_command_with_settings(self): + "alternate: manage.py can execute user commands if settings are provided as argument" + args = ['noargs_command', '--settings=alternate_settings'] + out, err = self.run_manage(args) + self.assertOutput(out, "EXECUTE:NoArgsCommand options=[('pythonpath', None), ('settings', 'alternate_settings'), ('traceback', None), ('verbosity', '1')]") + self.assertNoOutput(err) + + def test_custom_command_with_environment(self): + "alternate: manage.py can execute user commands if settings are provided in environment" + args = ['noargs_command'] + out, err = self.run_manage(args, 'alternate_settings') + self.assertOutput(out, "EXECUTE:NoArgsCommand options=[('pythonpath', None), ('settings', None), ('traceback', None), ('verbosity', '1')]") + self.assertNoOutput(err) + + +class ManageMultipleSettings(AdminScriptTestCase): + """A series of tests for manage.py when multiple settings files + (including the default 'settings.py') are available. The default settings + file is insufficient for performing the operations described, so the + alternate settings must be used by the running script. + """ + def setUp(self): + self.write_settings('settings.py', apps=['django.contrib.auth', 'django.contrib.contenttypes']) + self.write_settings('alternate_settings.py') + + def tearDown(self): + self.remove_settings('settings.py') + self.remove_settings('alternate_settings.py') + + def test_builtin_command(self): + "multiple: manage.py builtin commands fail with an error when no settings provided" + args = ['sqlall', 'admin_scripts'] + out, err = self.run_manage(args) + self.assertNoOutput(out) + self.assertOutput(err, 'App with label admin_scripts could not be found.') + + def test_builtin_with_settings(self): + "multiple: manage.py builtin commands succeed if settings are provided as argument" + args = ['sqlall', '--settings=alternate_settings', 'admin_scripts'] + out, err = self.run_manage(args) + self.assertNoOutput(err) + self.assertOutput(out, 'CREATE TABLE') + + def test_builtin_with_environment(self): + "multiple: manage.py can execute builtin commands if settings are provided in the environment" + args = ['sqlall', 'admin_scripts'] + out, err = self.run_manage(args, 'alternate_settings') + self.assertNoOutput(err) + self.assertOutput(out, 'CREATE TABLE') + + def test_builtin_with_bad_settings(self): + "multiple: manage.py builtin commands fail if settings file (from argument) doesn't exist" + args = ['sqlall', '--settings=bad_settings', 'admin_scripts'] + out, err = self.run_manage(args) + self.assertNoOutput(out) + self.assertOutput(err, "Could not import settings 'bad_settings'") + + def test_builtin_with_bad_environment(self): + "multiple: manage.py builtin commands fail if settings file (from environment) doesn't exist" + args = ['sqlall', 'admin_scripts'] + out, err = self.run_manage(args, 'bad_settings') + self.assertNoOutput(out) + self.assertOutput(err, "Could not import settings 'bad_settings'") + + def test_custom_command(self): + "multiple: manage.py can't execute user commands using default settings" + args = ['noargs_command'] + out, err = self.run_manage(args) + self.assertNoOutput(out) + self.assertOutput(err, "Unknown command: 'noargs_command'") + + def test_custom_command_with_settings(self): + "multiple: manage.py can execute user commands if settings are provided as argument" + args = ['noargs_command', '--settings=alternate_settings'] + out, err = self.run_manage(args) + self.assertNoOutput(err) + self.assertOutput(out, "EXECUTE:NoArgsCommand") + + def test_custom_command_with_environment(self): + "multiple: manage.py can execute user commands if settings are provided in environment" + args = ['noargs_command'] + out, err = self.run_manage(args, 'alternate_settings') + self.assertNoOutput(err) + self.assertOutput(out, "EXECUTE:NoArgsCommand") + + +class ManageSettingsWithImportError(AdminScriptTestCase): + """Tests for manage.py when using the default settings.py file + with an import error. Ticket #14130. + """ + def tearDown(self): + self.remove_settings('settings.py') + + def write_settings_with_import_error(self, filename, apps=None, is_dir=False, sdict=None): + if is_dir: + settings_dir = os.path.join(test_dir, filename) + os.mkdir(settings_dir) + settings_file_path = os.path.join(settings_dir, '__init__.py') + 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('# The next line will cause an import error:\nimport foo42bar\n') + + def test_builtin_command(self): + """ + import error: manage.py builtin commands shows useful diagnostic info + when settings with import errors is provided + """ + self.write_settings_with_import_error('settings.py') + args = ['sqlall', 'admin_scripts'] + out, err = self.run_manage(args) + self.assertNoOutput(out) + self.assertOutput(err, "No module named") + self.assertOutput(err, "foo42bar") + + def test_builtin_command_with_attribute_error(self): + """ + manage.py builtin commands does not swallow attribute errors from bad settings (#18845) + """ + self.write_settings('settings.py', sdict={'BAD_VAR': 'INSTALLED_APPS.crash'}) + args = ['collectstatic', 'admin_scripts'] + out, err = self.run_manage(args) + self.assertNoOutput(out) + self.assertOutput(err, "AttributeError: 'list' object has no attribute 'crash'") + + +class ManageValidate(AdminScriptTestCase): + def tearDown(self): + self.remove_settings('settings.py') + + def test_nonexistent_app(self): + "manage.py validate reports an error on a non-existent app in INSTALLED_APPS" + self.write_settings('settings.py', apps=['admin_scriptz.broken_app'], sdict={'USE_I18N': False}) + args = ['validate'] + out, err = self.run_manage(args) + self.assertNoOutput(out) + self.assertOutput(err, 'No module named') + self.assertOutput(err, 'admin_scriptz') + + def test_broken_app(self): + "manage.py validate reports an ImportError if an app's models.py raises one on import" + self.write_settings('settings.py', apps=['admin_scripts.broken_app']) + args = ['validate'] + out, err = self.run_manage(args) + self.assertNoOutput(out) + self.assertOutput(err, 'ImportError') + + def test_complex_app(self): + "manage.py validate does not raise an ImportError validating a complex app with nested calls to load_app" + self.write_settings('settings.py', + apps=['admin_scripts.complex_app', 'admin_scripts.simple_app'], + sdict={'DEBUG': True}) + args = ['validate'] + out, err = self.run_manage(args) + self.assertNoOutput(err) + self.assertOutput(out, '0 errors found') + + def test_app_with_import(self): + "manage.py validate does not raise errors when an app imports a base class that itself has an abstract base" + self.write_settings('settings.py', + apps=['admin_scripts.app_with_import', + 'django.contrib.comments', + 'django.contrib.auth', + 'django.contrib.contenttypes', + 'django.contrib.sites'], + sdict={'DEBUG': True}) + args = ['validate'] + out, err = self.run_manage(args) + self.assertNoOutput(err) + self.assertOutput(out, '0 errors found') + + +class CustomTestRunner(DjangoTestSuiteRunner): + + def __init__(self, *args, **kwargs): + assert 'liveserver' not in kwargs + super(CustomTestRunner, self).__init__(*args, **kwargs) + + def run_tests(self, test_labels, extra_tests=None, **kwargs): + pass + +class ManageTestCommand(AdminScriptTestCase): + def setUp(self): + from django.core.management.commands.test import Command as TestCommand + self.cmd = TestCommand() + + def test_liveserver(self): + """ + Ensure that the --liveserver option sets the environment variable + correctly. + Refs #2879. + """ + + # Backup original state + 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') + + # 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', + liveserver='blah') + + # Variable was correctly set + self.assertEqual(os.environ['DJANGO_LIVE_TEST_SERVER_ADDRESS'], 'blah') + + # Restore original state + if address_predefined: + os.environ['DJANGO_LIVE_TEST_SERVER_ADDRESS'] = old_address + else: + del os.environ['DJANGO_LIVE_TEST_SERVER_ADDRESS'] + + +class ManageRunserver(AdminScriptTestCase): + def setUp(self): + from django.core.management.commands.runserver import Command + + def monkey_run(*args, **options): + return + + self.cmd = Command() + self.cmd.run = monkey_run + + def assertServerSettings(self, addr, port, ipv6=None, raw_ipv6=False): + self.assertEqual(self.cmd.addr, addr) + self.assertEqual(self.cmd.port, port) + self.assertEqual(self.cmd.use_ipv6, ipv6) + self.assertEqual(self.cmd._raw_ipv6, raw_ipv6) + + def test_runserver_addrport(self): + self.cmd.handle() + self.assertServerSettings('127.0.0.1', '8000') + + self.cmd.handle(addrport="1.2.3.4:8000") + self.assertServerSettings('1.2.3.4', '8000') + + self.cmd.handle(addrport="7000") + self.assertServerSettings('127.0.0.1', '7000') + + @unittest.skipUnless(socket.has_ipv6, "platform doesn't support IPv6") + def test_runner_addrport_ipv6(self): + self.cmd.handle(addrport="", use_ipv6=True) + self.assertServerSettings('::1', '8000', ipv6=True, raw_ipv6=True) + + self.cmd.handle(addrport="7000", use_ipv6=True) + self.assertServerSettings('::1', '7000', ipv6=True, raw_ipv6=True) + + self.cmd.handle(addrport="[2001:0db8:1234:5678::9]:7000") + self.assertServerSettings('2001:0db8:1234:5678::9', '7000', ipv6=True, raw_ipv6=True) + + def test_runner_hostname(self): + self.cmd.handle(addrport="localhost:8000") + self.assertServerSettings('localhost', '8000') + + self.cmd.handle(addrport="test.domain.local:7000") + self.assertServerSettings('test.domain.local', '7000') + + @unittest.skipUnless(socket.has_ipv6, "platform doesn't support IPv6") + def test_runner_hostname_ipv6(self): + self.cmd.handle(addrport="test.domain.local:7000", use_ipv6=True) + self.assertServerSettings('test.domain.local', '7000', ipv6=True) + + def test_runner_ambiguous(self): + # Only 4 characters, all of which could be in an ipv6 address + self.cmd.handle(addrport="beef:7654") + self.assertServerSettings('beef', '7654') + + # Uses only characters that could be in an ipv6 address + self.cmd.handle(addrport="deadbeef:7654") + self.assertServerSettings('deadbeef', '7654') + + +########################################################################## +# COMMAND PROCESSING TESTS +# Check that user-space commands are correctly handled - in particular, +# that arguments to the commands are correctly parsed and processed. +########################################################################## + +class CommandTypes(AdminScriptTestCase): + "Tests for the various types of base command types that can be defined." + def setUp(self): + self.write_settings('settings.py') + + def tearDown(self): + self.remove_settings('settings.py') + + def test_version(self): + "version is handled as a special case" + args = ['version'] + out, err = self.run_manage(args) + self.assertNoOutput(err) + self.assertOutput(out, get_version()) + + def test_version_alternative(self): + "--version is equivalent to version" + args1, args2 = ['version'], ['--version'] + self.assertEqual(self.run_manage(args1), self.run_manage(args2)) + + def test_help(self): + "help is handled as a special case" + args = ['help'] + out, err = self.run_manage(args) + self.assertOutput(out, "Usage: manage.py subcommand [options] [args]") + self.assertOutput(out, "Type 'manage.py help ' for help on a specific subcommand.") + self.assertOutput(out, '[django]') + self.assertOutput(out, 'startapp') + self.assertOutput(out, 'startproject') + + def test_help_commands(self): + "help --commands shows the list of all available commands" + args = ['help', '--commands'] + out, err = self.run_manage(args) + self.assertNotInOutput(out, 'Usage:') + self.assertNotInOutput(out, 'Options:') + self.assertNotInOutput(out, '[django]') + self.assertOutput(out, 'startapp') + self.assertOutput(out, 'startproject') + self.assertNotInOutput(out, '\n\n') + + def test_help_alternative(self): + "--help is equivalent to help" + args1, args2 = ['help'], ['--help'] + self.assertEqual(self.run_manage(args1), self.run_manage(args2)) + + def test_help_short_altert(self): + "-h is handled as a short form of --help" + args1, args2 = ['--help'], ['-h'] + self.assertEqual(self.run_manage(args1), self.run_manage(args2)) + + def test_specific_help(self): + "--help can be used on a specific command" + args = ['sqlall', '--help'] + out, err = self.run_manage(args) + self.assertNoOutput(err) + self.assertOutput(out, "Prints the CREATE TABLE, custom SQL and CREATE INDEX SQL statements for the given model module name(s).") + + def test_base_command(self): + "User BaseCommands can execute when a label is provided" + args = ['base_command', 'testlabel'] + out, err = self.run_manage(args) + self.assertNoOutput(err) + self.assertOutput(out, "EXECUTE:BaseCommand labels=('testlabel',), options=[('option_a', '1'), ('option_b', '2'), ('option_c', '3'), ('pythonpath', None), ('settings', None), ('traceback', None), ('verbosity', '1')]") + + def test_base_command_no_label(self): + "User BaseCommands can execute when no labels are provided" + args = ['base_command'] + out, err = self.run_manage(args) + self.assertNoOutput(err) + self.assertOutput(out, "EXECUTE:BaseCommand labels=(), options=[('option_a', '1'), ('option_b', '2'), ('option_c', '3'), ('pythonpath', None), ('settings', None), ('traceback', None), ('verbosity', '1')]") + + def test_base_command_multiple_label(self): + "User BaseCommands can execute when no labels are provided" + args = ['base_command', 'testlabel', 'anotherlabel'] + out, err = self.run_manage(args) + self.assertNoOutput(err) + self.assertOutput(out, "EXECUTE:BaseCommand labels=('testlabel', 'anotherlabel'), options=[('option_a', '1'), ('option_b', '2'), ('option_c', '3'), ('pythonpath', None), ('settings', None), ('traceback', None), ('verbosity', '1')]") + + def test_base_command_with_option(self): + "User BaseCommands can execute with options when a label is provided" + args = ['base_command', 'testlabel', '--option_a=x'] + out, err = self.run_manage(args) + self.assertNoOutput(err) + self.assertOutput(out, "EXECUTE:BaseCommand labels=('testlabel',), options=[('option_a', 'x'), ('option_b', '2'), ('option_c', '3'), ('pythonpath', None), ('settings', None), ('traceback', None), ('verbosity', '1')]") + + def test_base_command_with_options(self): + "User BaseCommands can execute with multiple options when a label is provided" + args = ['base_command', 'testlabel', '-a', 'x', '--option_b=y'] + out, err = self.run_manage(args) + self.assertNoOutput(err) + self.assertOutput(out, "EXECUTE:BaseCommand labels=('testlabel',), options=[('option_a', 'x'), ('option_b', 'y'), ('option_c', '3'), ('pythonpath', None), ('settings', None), ('traceback', None), ('verbosity', '1')]") + + def test_base_run_from_argv(self): + """ + Test run_from_argv properly terminates even with custom execute() (#19665) + Also test proper traceback display. + """ + command = BaseCommand() + command.execute = lambda args: args # This will trigger TypeError + + old_stderr = sys.stderr + sys.stderr = err = StringIO() + try: + with self.assertRaises(SystemExit): + command.run_from_argv(['', '']) + err_message = err.getvalue() + self.assertNotIn("Traceback", err_message) + self.assertIn("TypeError", err_message) + + with self.assertRaises(SystemExit): + command.run_from_argv(['', '', '--traceback']) + err_message = err.getvalue() + self.assertIn("Traceback (most recent call last)", err_message) + self.assertIn("TypeError", err_message) + finally: + sys.stderr = old_stderr + + def test_noargs(self): + "NoArg Commands can be executed" + args = ['noargs_command'] + out, err = self.run_manage(args) + self.assertNoOutput(err) + self.assertOutput(out, "EXECUTE:NoArgsCommand options=[('pythonpath', None), ('settings', None), ('traceback', None), ('verbosity', '1')]") + + def test_noargs_with_args(self): + "NoArg Commands raise an error if an argument is provided" + args = ['noargs_command', 'argument'] + out, err = self.run_manage(args) + self.assertOutput(err, "Error: Command doesn't accept any arguments") + + def test_app_command(self): + "User AppCommands can execute when a single app name is provided" + args = ['app_command', 'auth'] + out, err = self.run_manage(args) + self.assertNoOutput(err) + self.assertOutput(out, "EXECUTE:AppCommand app=, options=[('pythonpath', None), ('settings', None), ('traceback', None), ('verbosity', '1')]") + + def test_app_command_no_apps(self): + "User AppCommands raise an error when no app name is provided" + args = ['app_command'] + out, err = self.run_manage(args) + self.assertOutput(err, 'Error: Enter at least one appname.') + + def test_app_command_multiple_apps(self): + "User AppCommands raise an error when multiple app names are provided" + args = ['app_command', 'auth', 'contenttypes'] + out, err = self.run_manage(args) + self.assertNoOutput(err) + self.assertOutput(out, "EXECUTE:AppCommand app=, options=[('pythonpath', None), ('settings', None), ('traceback', None), ('verbosity', '1')]") + self.assertOutput(out, "EXECUTE:AppCommand app=, options=[('pythonpath', None), ('settings', None), ('traceback', None), ('verbosity', '1')]") + + def test_app_command_invalid_appname(self): + "User AppCommands can execute when a single app name is provided" + args = ['app_command', 'NOT_AN_APP'] + out, err = self.run_manage(args) + self.assertOutput(err, "App with label NOT_AN_APP could not be found") + + def test_app_command_some_invalid_appnames(self): + "User AppCommands can execute when some of the provided app names are invalid" + args = ['app_command', 'auth', 'NOT_AN_APP'] + out, err = self.run_manage(args) + self.assertOutput(err, "App with label NOT_AN_APP could not be found") + + def test_label_command(self): + "User LabelCommands can execute when a label is provided" + args = ['label_command', 'testlabel'] + out, err = self.run_manage(args) + self.assertNoOutput(err) + self.assertOutput(out, "EXECUTE:LabelCommand label=testlabel, options=[('pythonpath', None), ('settings', None), ('traceback', None), ('verbosity', '1')]") + + def test_label_command_no_label(self): + "User LabelCommands raise an error if no label is provided" + args = ['label_command'] + out, err = self.run_manage(args) + self.assertOutput(err, 'Enter at least one label') + + def test_label_command_multiple_label(self): + "User LabelCommands are executed multiple times if multiple labels are provided" + args = ['label_command', 'testlabel', 'anotherlabel'] + out, err = self.run_manage(args) + self.assertNoOutput(err) + self.assertOutput(out, "EXECUTE:LabelCommand label=testlabel, options=[('pythonpath', None), ('settings', None), ('traceback', None), ('verbosity', '1')]") + self.assertOutput(out, "EXECUTE:LabelCommand label=anotherlabel, options=[('pythonpath', None), ('settings', None), ('traceback', None), ('verbosity', '1')]") + +class ArgumentOrder(AdminScriptTestCase): + """Tests for 2-stage argument parsing scheme. + + django-admin command arguments are parsed in 2 parts; the core arguments + (--settings, --traceback and --pythonpath) are parsed using a Lax parser. + This Lax parser ignores any unknown options. Then the full settings are + passed to the command parser, which extracts commands of interest to the + individual command. + """ + def setUp(self): + self.write_settings('settings.py', apps=['django.contrib.auth', 'django.contrib.contenttypes']) + self.write_settings('alternate_settings.py') + + def tearDown(self): + self.remove_settings('settings.py') + self.remove_settings('alternate_settings.py') + + def test_setting_then_option(self): + "Options passed after settings are correctly handled" + args = ['base_command', 'testlabel', '--settings=alternate_settings', '--option_a=x'] + out, err = self.run_manage(args) + self.assertNoOutput(err) + self.assertOutput(out, "EXECUTE:BaseCommand labels=('testlabel',), options=[('option_a', 'x'), ('option_b', '2'), ('option_c', '3'), ('pythonpath', None), ('settings', 'alternate_settings'), ('traceback', None), ('verbosity', '1')]") + + def test_setting_then_short_option(self): + "Short options passed after settings are correctly handled" + args = ['base_command', 'testlabel', '--settings=alternate_settings', '--option_a=x'] + out, err = self.run_manage(args) + self.assertNoOutput(err) + self.assertOutput(out, "EXECUTE:BaseCommand labels=('testlabel',), options=[('option_a', 'x'), ('option_b', '2'), ('option_c', '3'), ('pythonpath', None), ('settings', 'alternate_settings'), ('traceback', None), ('verbosity', '1')]") + + def test_option_then_setting(self): + "Options passed before settings are correctly handled" + args = ['base_command', 'testlabel', '--option_a=x', '--settings=alternate_settings'] + out, err = self.run_manage(args) + self.assertNoOutput(err) + self.assertOutput(out, "EXECUTE:BaseCommand labels=('testlabel',), options=[('option_a', 'x'), ('option_b', '2'), ('option_c', '3'), ('pythonpath', None), ('settings', 'alternate_settings'), ('traceback', None), ('verbosity', '1')]") + + def test_short_option_then_setting(self): + "Short options passed before settings are correctly handled" + args = ['base_command', 'testlabel', '-a', 'x', '--settings=alternate_settings'] + out, err = self.run_manage(args) + self.assertNoOutput(err) + self.assertOutput(out, "EXECUTE:BaseCommand labels=('testlabel',), options=[('option_a', 'x'), ('option_b', '2'), ('option_c', '3'), ('pythonpath', None), ('settings', 'alternate_settings'), ('traceback', None), ('verbosity', '1')]") + + def test_option_then_setting_then_option(self): + "Options are correctly handled when they are passed before and after a setting" + args = ['base_command', 'testlabel', '--option_a=x', '--settings=alternate_settings', '--option_b=y'] + out, err = self.run_manage(args) + self.assertNoOutput(err) + self.assertOutput(out, "EXECUTE:BaseCommand labels=('testlabel',), options=[('option_a', 'x'), ('option_b', 'y'), ('option_c', '3'), ('pythonpath', None), ('settings', 'alternate_settings'), ('traceback', None), ('verbosity', '1')]") + + +class StartProject(LiveServerTestCase, AdminScriptTestCase): + + def test_wrong_args(self): + "Make sure passing the wrong kinds of arguments raises a CommandError" + out, err = self.run_django_admin(['startproject']) + self.assertNoOutput(out) + self.assertOutput(err, "you must provide a project name") + + def test_simple_project(self): + "Make sure the startproject management command creates a project" + args = ['startproject', 'testproject'] + testproject_dir = os.path.join(test_dir, 'testproject') + self.addCleanup(shutil.rmtree, testproject_dir, True) + + out, err = self.run_django_admin(args) + self.assertNoOutput(err) + self.assertTrue(os.path.isdir(testproject_dir)) + + # running again.. + out, err = self.run_django_admin(args) + self.assertNoOutput(out) + self.assertOutput(err, "already exists") + + def test_invalid_project_name(self): + "Make sure the startproject management command validates a project name" + for bad_name in ('7testproject', '../testproject'): + args = ['startproject', bad_name] + testproject_dir = os.path.join(test_dir, bad_name) + self.addCleanup(shutil.rmtree, testproject_dir, True) + + out, err = self.run_django_admin(args) + self.assertOutput(err, "Error: '%s' is not a valid project name. " + "Please make sure the name begins with a letter or underscore." % bad_name) + self.assertFalse(os.path.exists(testproject_dir)) + + def test_simple_project_different_directory(self): + "Make sure the startproject management command creates a project in a specific directory" + args = ['startproject', 'testproject', 'othertestproject'] + testproject_dir = os.path.join(test_dir, 'othertestproject') + os.mkdir(testproject_dir) + self.addCleanup(shutil.rmtree, testproject_dir) + + out, err = self.run_django_admin(args) + self.assertNoOutput(err) + self.assertTrue(os.path.exists(os.path.join(testproject_dir, 'manage.py'))) + + # running again.. + out, err = self.run_django_admin(args) + self.assertNoOutput(out) + self.assertOutput(err, "already exists") + + 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') + args = ['startproject', '--template', template_path, 'customtestproject'] + testproject_dir = os.path.join(test_dir, 'customtestproject') + self.addCleanup(shutil.rmtree, testproject_dir, True) + + out, err = self.run_django_admin(args) + self.assertNoOutput(err) + self.assertTrue(os.path.isdir(testproject_dir)) + self.assertTrue(os.path.exists(os.path.join(testproject_dir, 'additional_dir'))) + + 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) + args = ['startproject', '--template', template_path, 'customtestproject'] + testproject_dir = os.path.join(test_dir, 'customtestproject') + self.addCleanup(shutil.rmtree, testproject_dir, True) + + out, err = self.run_django_admin(args) + self.assertNoOutput(err) + self.assertTrue(os.path.isdir(testproject_dir)) + self.assertTrue(os.path.exists(os.path.join(testproject_dir, 'additional_dir'))) + + 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') + args = ['startproject', '--template', template_path, 'tarballtestproject'] + testproject_dir = os.path.join(test_dir, 'tarballtestproject') + self.addCleanup(shutil.rmtree, testproject_dir, True) + + out, err = self.run_django_admin(args) + self.assertNoOutput(err) + self.assertTrue(os.path.isdir(testproject_dir)) + self.assertTrue(os.path.exists(os.path.join(testproject_dir, 'run.py'))) + + 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') + args = ['startproject', '--template', template_path, 'tarballtestproject', 'altlocation'] + testproject_dir = os.path.join(test_dir, 'altlocation') + os.mkdir(testproject_dir) + self.addCleanup(shutil.rmtree, testproject_dir) + + out, err = self.run_django_admin(args) + self.assertNoOutput(err) + self.assertTrue(os.path.isdir(testproject_dir)) + self.assertTrue(os.path.exists(os.path.join(testproject_dir, 'run.py'))) + + def test_custom_project_template_from_tarball_by_url(self): + "Make sure the startproject management command is able to use a different project template from a tarball via a url" + template_url = '%s/admin_scripts/custom_templates/project_template.tgz' % self.live_server_url + + args = ['startproject', '--template', template_url, 'urltestproject'] + testproject_dir = os.path.join(test_dir, 'urltestproject') + self.addCleanup(shutil.rmtree, testproject_dir, True) + + out, err = self.run_django_admin(args) + self.assertNoOutput(err) + self.assertTrue(os.path.isdir(testproject_dir)) + self.assertTrue(os.path.exists(os.path.join(testproject_dir, 'run.py'))) + + def test_project_template_tarball_url(self): + "Startproject management command handles project template tar/zip balls from non-canonical urls" + template_url = '%s/admin_scripts/custom_templates/project_template.tgz/' % self.live_server_url + + args = ['startproject', '--template', template_url, 'urltestproject'] + testproject_dir = os.path.join(test_dir, 'urltestproject') + self.addCleanup(shutil.rmtree, testproject_dir, True) + + out, err = self.run_django_admin(args) + self.assertNoOutput(err) + self.assertTrue(os.path.isdir(testproject_dir)) + self.assertTrue(os.path.exists(os.path.join(testproject_dir, 'run.py'))) + + 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') + 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) + + out, err = self.run_django_admin(args) + self.assertNoOutput(err) + self.assertTrue(os.path.isdir(testproject_dir)) + self.assertTrue(os.path.exists(os.path.join(testproject_dir, 'additional_dir'))) + base_path = os.path.join(testproject_dir, 'additional_dir') + for f in ('Procfile', 'additional_file.py', 'requirements.txt'): + self.assertTrue(os.path.exists(os.path.join(base_path, f))) + with open(os.path.join(base_path, f)) as fh: + self.assertEqual(fh.read(), + '# some file for customtestproject test project') + + 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') + args = ['startproject', '--template', template_path, 'another_project', 'project_dir'] + testproject_dir = os.path.join(test_dir, 'project_dir') + os.mkdir(testproject_dir) + self.addCleanup(shutil.rmtree, testproject_dir) + out, err = self.run_django_admin(args) + self.assertNoOutput(err) + test_manage_py = os.path.join(testproject_dir, 'manage.py') + with open(test_manage_py, 'r') as fp: + content = force_text(fp.read()) + self.assertIn("project_name = 'another_project'", content) + self.assertIn("project_directory = '%s'" % testproject_dir, content) + + def test_no_escaping_of_project_variables(self): + "Make sure template context variables are not html escaped" + # 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') + 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) + self.addCleanup(shutil.rmtree, testproject_dir) + out, err = self.run_manage(args) + self.assertNoOutput(err) + test_manage_py = os.path.join(testproject_dir, 'additional_dir', 'extra.py') + with open(test_manage_py, 'r') as fp: + content = fp.read() + self.assertIn("<&>", content) + + def test_custom_project_destination_missing(self): + """ + 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') + 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) + self.assertNoOutput(out) + self.assertOutput(err, "Destination directory '%s' does not exist, please create it first." % testproject_dir) + self.assertFalse(os.path.exists(testproject_dir)) + + 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') + args = ['startproject', '--template', template_path, '--extension=txt', 'customtestproject'] + testproject_dir = os.path.join(test_dir, 'customtestproject') + self.addCleanup(shutil.rmtree, testproject_dir, True) + + out, err = self.run_django_admin(args) + self.assertNoOutput(err) + self.assertTrue(os.path.isdir(testproject_dir)) + path = os.path.join(testproject_dir, 'ticket-18091-non-ascii-template.txt') + with codecs.open(path, 'r', 'utf-8') as f: + self.assertEqual(f.read(), + 'Some non-ASCII text for testing ticket #18091:\nüäö €\n') + + +class DiffSettings(AdminScriptTestCase): + """Tests for diffsettings management command.""" + def test_basic(self): + "Runs without error and emits settings diff." + self.write_settings('settings_to_diff.py', sdict={'FOO': '"bar"'}) + self.addCleanup(self.remove_settings, 'settings_to_diff.py') + args = ['diffsettings', '--settings=settings_to_diff'] + out, err = self.run_manage(args) + self.assertNoOutput(err) + self.assertOutput(out, "FOO = 'bar' ###") -- cgit v1.3 From 33836cf88dd08ebd66d19ad7f732b12f089abd27 Mon Sep 17 00:00:00 2001 From: Florian Apolloner Date: Tue, 26 Feb 2013 13:19:18 +0100 Subject: Renamed some tests and removed references to modeltests/regressiontests. --- tests/admin_changelist/tests.py | 2 +- tests/admin_inlines/tests.py | 10 +- tests/admin_scripts/tests.py | 135 +- tests/admin_validation/tests.py | 2 +- tests/admin_views/tests.py | 68 +- tests/admin_widgets/tests.py | 4 +- tests/cache/tests.py | 14 +- tests/commands_sql/tests.py | 2 +- tests/comment_tests/custom_comments/__init__.py | 14 +- tests/comment_tests/tests/__init__.py | 18 +- tests/comment_tests/tests/app_api_tests.py | 12 +- tests/comment_tests/tests/feed_tests.py | 2 +- tests/comment_tests/tests/moderation_view_tests.py | 2 +- tests/conditional_processing/models.py | 2 +- tests/context_processors/tests.py | 2 +- tests/empty/no_models/tests.py | 2 +- tests/empty/tests.py | 2 +- tests/file_storage/tests.py | 2 +- tests/forms/__init__.py | 0 tests/forms/models.py | 90 - tests/forms/templates/forms/article_form.html | 8 - tests/forms/tests/__init__.py | 21 - tests/forms/tests/error_messages.py | 263 --- tests/forms/tests/extra.py | 807 --------- tests/forms/tests/fields.py | 1190 ------------- tests/forms/tests/filepath_test_files/.dot-file | 0 .../tests/filepath_test_files/directory/.keep | 0 .../forms/tests/filepath_test_files/fake-image.jpg | 0 .../tests/filepath_test_files/real-text-file.txt | 0 tests/forms/tests/forms.py | 1799 ------------------- tests/forms/tests/formsets.py | 1055 ------------ tests/forms/tests/input_formats.py | 861 --------- tests/forms/tests/media.py | 907 ---------- tests/forms/tests/models.py | 218 --- tests/forms/tests/regressions.py | 150 -- tests/forms/tests/util.py | 67 - tests/forms/tests/validators.py | 16 - tests/forms/tests/widgets.py | 1124 ------------ tests/forms/urls.py | 9 - tests/forms/views.py | 8 - tests/forms_tests/__init__.py | 0 tests/forms_tests/models.py | 90 + .../forms_tests/templates/forms/article_form.html | 8 + tests/forms_tests/tests/__init__.py | 21 + tests/forms_tests/tests/error_messages.py | 263 +++ tests/forms_tests/tests/extra.py | 807 +++++++++ tests/forms_tests/tests/fields.py | 1190 +++++++++++++ .../tests/filepath_test_files/.dot-file | 0 .../tests/filepath_test_files/directory/.keep | 0 .../tests/filepath_test_files/fake-image.jpg | 0 .../tests/filepath_test_files/real-text-file.txt | 0 tests/forms_tests/tests/forms.py | 1799 +++++++++++++++++++ tests/forms_tests/tests/formsets.py | 1055 ++++++++++++ tests/forms_tests/tests/input_formats.py | 861 +++++++++ tests/forms_tests/tests/media.py | 907 ++++++++++ tests/forms_tests/tests/models.py | 218 +++ tests/forms_tests/tests/regressions.py | 150 ++ tests/forms_tests/tests/util.py | 67 + tests/forms_tests/tests/validators.py | 16 + tests/forms_tests/tests/widgets.py | 1124 ++++++++++++ tests/forms_tests/urls.py | 9 + tests/forms_tests/views.py | 8 + tests/generic_inline_admin/tests.py | 10 +- tests/generic_views/base.py | 2 +- tests/generic_views/dates.py | 12 +- tests/generic_views/detail.py | 2 +- tests/generic_views/edit.py | 8 +- tests/generic_views/list.py | 2 +- tests/handlers/tests.py | 2 +- tests/i18n/patterns/tests.py | 8 +- tests/i18n/patterns/urls/default.py | 2 +- tests/i18n/patterns/urls/wrong.py | 2 +- tests/i18n/tests.py | 10 +- tests/inline_formsets/tests.py | 6 +- tests/invalid_models/tests.py | 2 +- tests/logging_tests/tests.py | 8 +- tests/mail/tests.py | 10 +- tests/middleware/tests.py | 22 +- tests/middleware_exceptions/tests.py | 12 +- tests/model_inheritance_same_model_name/models.py | 2 +- tests/model_inheritance_same_model_name/tests.py | 6 +- tests/model_permalink/tests.py | 2 +- tests/runtests.py | 5 +- tests/servers/tests.py | 2 +- tests/special_headers/tests.py | 6 +- tests/staticfiles_tests/tests.py | 12 +- tests/swappable_models/tests.py | 2 +- tests/syndication/tests.py | 2 +- tests/template_tests/__init__.py | 0 tests/template_tests/alternate_urls.py | 16 + tests/template_tests/callables.py | 113 ++ tests/template_tests/context.py | 16 + tests/template_tests/custom.py | 377 ++++ tests/template_tests/eggs/tagsegg.egg | Bin 0 -> 2581 bytes tests/template_tests/filters.py | 371 ++++ tests/template_tests/loaders.py | 156 ++ tests/template_tests/models.py | 0 tests/template_tests/nodelist.py | 58 + tests/template_tests/parser.py | 95 + tests/template_tests/response.py | 352 ++++ tests/template_tests/smartif.py | 53 + tests/template_tests/templates/broken_base.html | 1 + tests/template_tests/templates/first/test.html | 1 + tests/template_tests/templates/inclusion.html | 1 + tests/template_tests/templates/response.html | 2 + tests/template_tests/templates/second/test.html | 1 + .../templates/ssi include with spaces.html | 1 + tests/template_tests/templates/ssi_include.html | 1 + tests/template_tests/templates/test_context.html | 1 + .../templates/test_extends_error.html | 1 + .../templates/test_incl_tag_current_app.html | 1 + .../templates/test_incl_tag_use_l10n.html | 1 + .../templates/test_include_error.html | 1 + tests/template_tests/templatetags/__init__.py | 0 tests/template_tests/templatetags/bad_tag.py | 12 + tests/template_tests/templatetags/broken_tag.py | 1 + tests/template_tests/templatetags/custom.py | 313 ++++ .../templatetags/subpackage/__init__.py | 0 .../template_tests/templatetags/subpackage/echo.py | 7 + .../templatetags/subpackage/echo_invalid.py | 1 + tests/template_tests/tests.py | 1818 ++++++++++++++++++++ tests/template_tests/unicode.py | 32 + tests/template_tests/urls.py | 20 + tests/template_tests/views.py | 22 + tests/templates/__init__.py | 0 tests/templates/alternate_urls.py | 16 - tests/templates/base.html | 8 + tests/templates/callables.py | 113 -- .../comments/comment_notification_email.txt | 3 + tests/templates/context.py | 16 - tests/templates/custom.py | 377 ---- tests/templates/custom_admin/add_form.html | 1 + tests/templates/custom_admin/change_form.html | 1 + tests/templates/custom_admin/change_list.html | 7 + .../custom_admin/delete_confirmation.html | 1 + .../custom_admin/delete_selected_confirmation.html | 1 + tests/templates/custom_admin/index.html | 6 + tests/templates/custom_admin/login.html | 6 + tests/templates/custom_admin/logout.html | 6 + tests/templates/custom_admin/object_history.html | 1 + .../custom_admin/password_change_done.html | 6 + .../custom_admin/password_change_form.html | 6 + tests/templates/eggs/tagsegg.egg | Bin 2581 -> 0 bytes tests/templates/extended.html | 5 + tests/templates/filters.py | 371 ---- tests/templates/form_view.html | 15 + tests/templates/loaders.py | 156 -- tests/templates/login.html | 17 + tests/templates/models.py | 0 tests/templates/nodelist.py | 58 - tests/templates/parser.py | 95 - tests/templates/response.py | 352 ---- tests/templates/smartif.py | 53 - tests/templates/templates/broken_base.html | 1 - tests/templates/templates/first/test.html | 1 - tests/templates/templates/inclusion.html | 1 - tests/templates/templates/response.html | 2 - tests/templates/templates/second/test.html | 1 - .../templates/ssi include with spaces.html | 1 - tests/templates/templates/ssi_include.html | 1 - tests/templates/templates/test_context.html | 1 - tests/templates/templates/test_extends_error.html | 1 - .../templates/test_incl_tag_current_app.html | 1 - .../templates/test_incl_tag_use_l10n.html | 1 - tests/templates/templates/test_include_error.html | 1 - tests/templates/templatetags/__init__.py | 0 tests/templates/templatetags/bad_tag.py | 12 - tests/templates/templatetags/broken_tag.py | 1 - tests/templates/templatetags/custom.py | 313 ---- .../templates/templatetags/subpackage/__init__.py | 0 tests/templates/templatetags/subpackage/echo.py | 7 - .../templatetags/subpackage/echo_invalid.py | 1 - tests/templates/tests.py | 1818 -------------------- tests/templates/unicode.py | 32 - tests/templates/urls.py | 20 - tests/templates/views.py | 22 - tests/templates/views/article_archive_day.html | 1 + tests/templates/views/article_archive_month.html | 1 + tests/templates/views/article_confirm_delete.html | 1 + tests/templates/views/article_detail.html | 1 + tests/templates/views/article_form.html | 3 + tests/templates/views/article_list.html | 1 + .../templates/views/datearticle_archive_month.html | 1 + tests/templates/views/urlarticle_detail.html | 1 + tests/templates/views/urlarticle_form.html | 3 + tests/test_client_regress/tests.py | 4 +- tests/test_runner/tests.py | 26 +- tests/test_templates/base.html | 8 - .../comments/comment_notification_email.txt | 3 - tests/test_templates/custom_admin/add_form.html | 1 - tests/test_templates/custom_admin/change_form.html | 1 - tests/test_templates/custom_admin/change_list.html | 7 - .../custom_admin/delete_confirmation.html | 1 - .../custom_admin/delete_selected_confirmation.html | 1 - tests/test_templates/custom_admin/index.html | 6 - tests/test_templates/custom_admin/login.html | 6 - tests/test_templates/custom_admin/logout.html | 6 - .../custom_admin/object_history.html | 1 - .../custom_admin/password_change_done.html | 6 - .../custom_admin/password_change_form.html | 6 - tests/test_templates/extended.html | 5 - tests/test_templates/form_view.html | 15 - tests/test_templates/login.html | 17 - .../test_templates/views/article_archive_day.html | 1 - .../views/article_archive_month.html | 1 - .../views/article_confirm_delete.html | 1 - tests/test_templates/views/article_detail.html | 1 - tests/test_templates/views/article_form.html | 3 - tests/test_templates/views/article_list.html | 1 - .../views/datearticle_archive_month.html | 1 - tests/test_templates/views/urlarticle_detail.html | 1 - tests/test_templates/views/urlarticle_form.html | 3 - tests/test_utils/tests.py | 4 +- tests/timezones/tests.py | 2 +- tests/urlpatterns_reverse/erroneous_urls.py | 10 +- tests/urlpatterns_reverse/extra_urls.py | 4 +- tests/urlpatterns_reverse/included_named_urls.py | 2 +- .../urlpatterns_reverse/included_namespace_urls.py | 6 +- tests/urlpatterns_reverse/named_urls.py | 2 +- tests/urlpatterns_reverse/namespace_urls.py | 14 +- tests/urlpatterns_reverse/tests.py | 38 +- tests/urlpatterns_reverse/urls.py | 4 +- tests/urlpatterns_reverse/urls_error_handlers.py | 4 +- tests/urls.py | 20 +- tests/utils/__init__.py | 0 tests/utils/archive.py | 72 - tests/utils/archives/foobar.tar | Bin 10240 -> 0 bytes tests/utils/archives/foobar.tar.bz2 | Bin 238 -> 0 bytes tests/utils/archives/foobar.tar.gz | Bin 249 -> 0 bytes tests/utils/archives/foobar.zip | Bin 1130 -> 0 bytes tests/utils/baseconv.py | 42 - tests/utils/checksums.py | 29 - tests/utils/crypto.py | 146 -- tests/utils/datastructures.py | 306 ---- tests/utils/dateformat.py | 142 -- tests/utils/dateparse.py | 44 - tests/utils/datetime_safe.py | 42 - tests/utils/decorators.py | 108 -- tests/utils/eggs/test_egg.egg | Bin 4844 -> 0 bytes tests/utils/encoding.py | 17 - tests/utils/feedgenerator.py | 117 -- tests/utils/functional.py | 66 - tests/utils/html.py | 161 -- tests/utils/http.py | 163 -- tests/utils/ipv6.py | 53 - tests/utils/jslex.py | 216 --- tests/utils/models.py | 1 - tests/utils/module_loading.py | 184 -- tests/utils/numberformat.py | 47 - tests/utils/os_utils.py | 26 - tests/utils/regex_helper.py | 50 - tests/utils/simplelazyobject.py | 123 -- tests/utils/termcolors.py | 157 -- tests/utils/test_module/__init__.py | 0 tests/utils/test_module/bad_module.py | 3 - tests/utils/test_module/good_module.py | 1 - tests/utils/test_no_submodule.py | 1 - tests/utils/tests.py | 33 - tests/utils/text.py | 108 -- tests/utils/timesince.py | 124 -- tests/utils/timezone.py | 63 - tests/utils/tzinfo.py | 79 - tests/utils_tests/__init__.py | 0 tests/utils_tests/archive.py | 72 + tests/utils_tests/archives/foobar.tar | Bin 0 -> 10240 bytes tests/utils_tests/archives/foobar.tar.bz2 | Bin 0 -> 238 bytes tests/utils_tests/archives/foobar.tar.gz | Bin 0 -> 249 bytes tests/utils_tests/archives/foobar.zip | Bin 0 -> 1130 bytes tests/utils_tests/baseconv.py | 42 + tests/utils_tests/checksums.py | 29 + tests/utils_tests/crypto.py | 146 ++ tests/utils_tests/datastructures.py | 306 ++++ tests/utils_tests/dateformat.py | 142 ++ tests/utils_tests/dateparse.py | 44 + tests/utils_tests/datetime_safe.py | 42 + tests/utils_tests/decorators.py | 108 ++ tests/utils_tests/eggs/test_egg.egg | Bin 0 -> 4844 bytes tests/utils_tests/encoding.py | 17 + tests/utils_tests/feedgenerator.py | 117 ++ tests/utils_tests/functional.py | 66 + tests/utils_tests/html.py | 161 ++ tests/utils_tests/http.py | 163 ++ tests/utils_tests/ipv6.py | 53 + tests/utils_tests/jslex.py | 216 +++ tests/utils_tests/models.py | 1 + tests/utils_tests/module_loading.py | 184 ++ tests/utils_tests/numberformat.py | 47 + tests/utils_tests/os_utils.py | 26 + tests/utils_tests/regex_helper.py | 50 + tests/utils_tests/simplelazyobject.py | 123 ++ tests/utils_tests/termcolors.py | 157 ++ tests/utils_tests/test_module/__init__.py | 0 tests/utils_tests/test_module/bad_module.py | 3 + tests/utils_tests/test_module/good_module.py | 1 + tests/utils_tests/test_no_submodule.py | 1 + tests/utils_tests/tests.py | 33 + tests/utils_tests/text.py | 108 ++ tests/utils_tests/timesince.py | 124 ++ tests/utils_tests/timezone.py | 63 + tests/utils_tests/tzinfo.py | 79 + tests/view_tests/__init__.py | 11 + tests/view_tests/app0/__init__.py | 1 + .../app0/locale/en/LC_MESSAGES/djangojs.mo | Bin 0 -> 482 bytes .../app0/locale/en/LC_MESSAGES/djangojs.po | 20 + tests/view_tests/app1/__init__.py | 1 + .../app1/locale/fr/LC_MESSAGES/djangojs.mo | Bin 0 -> 482 bytes .../app1/locale/fr/LC_MESSAGES/djangojs.po | 20 + tests/view_tests/app2/__init__.py | 1 + .../app2/locale/fr/LC_MESSAGES/djangojs.mo | Bin 0 -> 482 bytes .../app2/locale/fr/LC_MESSAGES/djangojs.po | 20 + tests/view_tests/app3/__init__.py | 1 + .../app3/locale/es_AR/LC_MESSAGES/djangojs.mo | Bin 0 -> 483 bytes .../app3/locale/es_AR/LC_MESSAGES/djangojs.po | 20 + tests/view_tests/app4/__init__.py | 1 + .../app4/locale/es_AR/LC_MESSAGES/djangojs.mo | Bin 0 -> 483 bytes .../app4/locale/es_AR/LC_MESSAGES/djangojs.po | 20 + tests/view_tests/fixtures/testdata.json | 75 + tests/view_tests/generic_urls.py | 57 + tests/view_tests/locale/de/LC_MESSAGES/djangojs.mo | Bin 0 -> 615 bytes tests/view_tests/locale/de/LC_MESSAGES/djangojs.po | 40 + tests/view_tests/locale/es/LC_MESSAGES/djangojs.mo | Bin 0 -> 490 bytes tests/view_tests/locale/es/LC_MESSAGES/djangojs.po | 25 + tests/view_tests/locale/fr/LC_MESSAGES/djangojs.mo | Bin 0 -> 519 bytes tests/view_tests/locale/fr/LC_MESSAGES/djangojs.po | 28 + tests/view_tests/locale/ru/LC_MESSAGES/djangojs.mo | Bin 0 -> 489 bytes tests/view_tests/locale/ru/LC_MESSAGES/djangojs.po | 24 + tests/view_tests/media/file.txt | 1 + tests/view_tests/media/file.txt.gz | Bin 0 -> 51 bytes tests/view_tests/media/file.unknown | 1 + tests/view_tests/models.py | 52 + tests/view_tests/templates/debug/render_test.html | 1 + .../templates/debug/template_exception.html | 2 + tests/view_tests/templates/jsi18n.html | 44 + tests/view_tests/templatetags/__init__.py | 0 tests/view_tests/templatetags/debugtags.py | 13 + tests/view_tests/tests/__init__.py | 10 + tests/view_tests/tests/debug.py | 559 ++++++ tests/view_tests/tests/defaults.py | 98 ++ tests/view_tests/tests/i18n.py | 221 +++ tests/view_tests/tests/shortcuts.py | 59 + tests/view_tests/tests/specials.py | 39 + tests/view_tests/tests/static.py | 120 ++ tests/view_tests/urls.py | 71 + tests/view_tests/views.py | 266 +++ tests/views/__init__.py | 11 - tests/views/app0/__init__.py | 1 - tests/views/app0/locale/en/LC_MESSAGES/djangojs.mo | Bin 482 -> 0 bytes tests/views/app0/locale/en/LC_MESSAGES/djangojs.po | 20 - tests/views/app1/__init__.py | 1 - tests/views/app1/locale/fr/LC_MESSAGES/djangojs.mo | Bin 482 -> 0 bytes tests/views/app1/locale/fr/LC_MESSAGES/djangojs.po | 20 - tests/views/app2/__init__.py | 1 - tests/views/app2/locale/fr/LC_MESSAGES/djangojs.mo | Bin 482 -> 0 bytes tests/views/app2/locale/fr/LC_MESSAGES/djangojs.po | 20 - tests/views/app3/__init__.py | 1 - .../app3/locale/es_AR/LC_MESSAGES/djangojs.mo | Bin 483 -> 0 bytes .../app3/locale/es_AR/LC_MESSAGES/djangojs.po | 20 - tests/views/app4/__init__.py | 1 - .../app4/locale/es_AR/LC_MESSAGES/djangojs.mo | Bin 483 -> 0 bytes .../app4/locale/es_AR/LC_MESSAGES/djangojs.po | 20 - tests/views/fixtures/testdata.json | 75 - tests/views/generic_urls.py | 57 - tests/views/locale/de/LC_MESSAGES/djangojs.mo | Bin 615 -> 0 bytes tests/views/locale/de/LC_MESSAGES/djangojs.po | 40 - tests/views/locale/es/LC_MESSAGES/djangojs.mo | Bin 490 -> 0 bytes tests/views/locale/es/LC_MESSAGES/djangojs.po | 25 - tests/views/locale/fr/LC_MESSAGES/djangojs.mo | Bin 519 -> 0 bytes tests/views/locale/fr/LC_MESSAGES/djangojs.po | 28 - tests/views/locale/ru/LC_MESSAGES/djangojs.mo | Bin 489 -> 0 bytes tests/views/locale/ru/LC_MESSAGES/djangojs.po | 24 - tests/views/media/file.txt | 1 - tests/views/media/file.txt.gz | Bin 51 -> 0 bytes tests/views/media/file.unknown | 1 - tests/views/models.py | 52 - tests/views/templates/debug/render_test.html | 1 - .../views/templates/debug/template_exception.html | 2 - tests/views/templates/jsi18n.html | 44 - tests/views/templatetags/__init__.py | 0 tests/views/templatetags/debugtags.py | 13 - tests/views/tests/__init__.py | 10 - tests/views/tests/debug.py | 559 ------ tests/views/tests/defaults.py | 98 -- tests/views/tests/i18n.py | 221 --- tests/views/tests/shortcuts.py | 59 - tests/views/tests/specials.py | 39 - tests/views/tests/static.py | 120 -- tests/views/urls.py | 71 - tests/views/views.py | 266 --- tests/wsgi/tests.py | 12 +- 389 files changed, 17495 insertions(+), 17487 deletions(-) delete mode 100644 tests/forms/__init__.py delete mode 100644 tests/forms/models.py delete mode 100644 tests/forms/templates/forms/article_form.html delete mode 100644 tests/forms/tests/__init__.py delete mode 100644 tests/forms/tests/error_messages.py delete mode 100644 tests/forms/tests/extra.py delete mode 100644 tests/forms/tests/fields.py delete mode 100644 tests/forms/tests/filepath_test_files/.dot-file delete mode 100644 tests/forms/tests/filepath_test_files/directory/.keep delete mode 100644 tests/forms/tests/filepath_test_files/fake-image.jpg delete mode 100644 tests/forms/tests/filepath_test_files/real-text-file.txt delete mode 100644 tests/forms/tests/forms.py delete mode 100644 tests/forms/tests/formsets.py delete mode 100644 tests/forms/tests/input_formats.py delete mode 100644 tests/forms/tests/media.py delete mode 100644 tests/forms/tests/models.py delete mode 100644 tests/forms/tests/regressions.py delete mode 100644 tests/forms/tests/util.py delete mode 100644 tests/forms/tests/validators.py delete mode 100644 tests/forms/tests/widgets.py delete mode 100644 tests/forms/urls.py delete mode 100644 tests/forms/views.py create mode 100644 tests/forms_tests/__init__.py create mode 100644 tests/forms_tests/models.py create mode 100644 tests/forms_tests/templates/forms/article_form.html create mode 100644 tests/forms_tests/tests/__init__.py create mode 100644 tests/forms_tests/tests/error_messages.py create mode 100644 tests/forms_tests/tests/extra.py create mode 100644 tests/forms_tests/tests/fields.py create mode 100644 tests/forms_tests/tests/filepath_test_files/.dot-file create mode 100644 tests/forms_tests/tests/filepath_test_files/directory/.keep create mode 100644 tests/forms_tests/tests/filepath_test_files/fake-image.jpg create mode 100644 tests/forms_tests/tests/filepath_test_files/real-text-file.txt create mode 100644 tests/forms_tests/tests/forms.py create mode 100644 tests/forms_tests/tests/formsets.py create mode 100644 tests/forms_tests/tests/input_formats.py create mode 100644 tests/forms_tests/tests/media.py create mode 100644 tests/forms_tests/tests/models.py create mode 100644 tests/forms_tests/tests/regressions.py create mode 100644 tests/forms_tests/tests/util.py create mode 100644 tests/forms_tests/tests/validators.py create mode 100644 tests/forms_tests/tests/widgets.py create mode 100644 tests/forms_tests/urls.py create mode 100644 tests/forms_tests/views.py create mode 100644 tests/template_tests/__init__.py create mode 100644 tests/template_tests/alternate_urls.py create mode 100644 tests/template_tests/callables.py create mode 100644 tests/template_tests/context.py create mode 100644 tests/template_tests/custom.py create mode 100644 tests/template_tests/eggs/tagsegg.egg create mode 100644 tests/template_tests/filters.py create mode 100644 tests/template_tests/loaders.py create mode 100644 tests/template_tests/models.py create mode 100644 tests/template_tests/nodelist.py create mode 100644 tests/template_tests/parser.py create mode 100644 tests/template_tests/response.py create mode 100644 tests/template_tests/smartif.py create mode 100644 tests/template_tests/templates/broken_base.html create mode 100644 tests/template_tests/templates/first/test.html create mode 100644 tests/template_tests/templates/inclusion.html create mode 100644 tests/template_tests/templates/response.html create mode 100644 tests/template_tests/templates/second/test.html create mode 100644 tests/template_tests/templates/ssi include with spaces.html create mode 100644 tests/template_tests/templates/ssi_include.html create mode 100644 tests/template_tests/templates/test_context.html create mode 100644 tests/template_tests/templates/test_extends_error.html create mode 100644 tests/template_tests/templates/test_incl_tag_current_app.html create mode 100644 tests/template_tests/templates/test_incl_tag_use_l10n.html create mode 100644 tests/template_tests/templates/test_include_error.html create mode 100644 tests/template_tests/templatetags/__init__.py create mode 100644 tests/template_tests/templatetags/bad_tag.py create mode 100644 tests/template_tests/templatetags/broken_tag.py create mode 100644 tests/template_tests/templatetags/custom.py create mode 100644 tests/template_tests/templatetags/subpackage/__init__.py create mode 100644 tests/template_tests/templatetags/subpackage/echo.py create mode 100644 tests/template_tests/templatetags/subpackage/echo_invalid.py create mode 100644 tests/template_tests/tests.py create mode 100644 tests/template_tests/unicode.py create mode 100644 tests/template_tests/urls.py create mode 100644 tests/template_tests/views.py delete mode 100644 tests/templates/__init__.py delete mode 100644 tests/templates/alternate_urls.py create mode 100644 tests/templates/base.html delete mode 100644 tests/templates/callables.py create mode 100644 tests/templates/comments/comment_notification_email.txt delete mode 100644 tests/templates/context.py delete mode 100644 tests/templates/custom.py create mode 100644 tests/templates/custom_admin/add_form.html create mode 100644 tests/templates/custom_admin/change_form.html create mode 100644 tests/templates/custom_admin/change_list.html create mode 100644 tests/templates/custom_admin/delete_confirmation.html create mode 100644 tests/templates/custom_admin/delete_selected_confirmation.html create mode 100644 tests/templates/custom_admin/index.html create mode 100644 tests/templates/custom_admin/login.html create mode 100644 tests/templates/custom_admin/logout.html create mode 100644 tests/templates/custom_admin/object_history.html create mode 100644 tests/templates/custom_admin/password_change_done.html create mode 100644 tests/templates/custom_admin/password_change_form.html delete mode 100644 tests/templates/eggs/tagsegg.egg create mode 100644 tests/templates/extended.html delete mode 100644 tests/templates/filters.py create mode 100644 tests/templates/form_view.html delete mode 100644 tests/templates/loaders.py create mode 100644 tests/templates/login.html delete mode 100644 tests/templates/models.py delete mode 100644 tests/templates/nodelist.py delete mode 100644 tests/templates/parser.py delete mode 100644 tests/templates/response.py delete mode 100644 tests/templates/smartif.py delete mode 100644 tests/templates/templates/broken_base.html delete mode 100644 tests/templates/templates/first/test.html delete mode 100644 tests/templates/templates/inclusion.html delete mode 100644 tests/templates/templates/response.html delete mode 100644 tests/templates/templates/second/test.html delete mode 100644 tests/templates/templates/ssi include with spaces.html delete mode 100644 tests/templates/templates/ssi_include.html delete mode 100644 tests/templates/templates/test_context.html delete mode 100644 tests/templates/templates/test_extends_error.html delete mode 100644 tests/templates/templates/test_incl_tag_current_app.html delete mode 100644 tests/templates/templates/test_incl_tag_use_l10n.html delete mode 100644 tests/templates/templates/test_include_error.html delete mode 100644 tests/templates/templatetags/__init__.py delete mode 100644 tests/templates/templatetags/bad_tag.py delete mode 100644 tests/templates/templatetags/broken_tag.py delete mode 100644 tests/templates/templatetags/custom.py delete mode 100644 tests/templates/templatetags/subpackage/__init__.py delete mode 100644 tests/templates/templatetags/subpackage/echo.py delete mode 100644 tests/templates/templatetags/subpackage/echo_invalid.py delete mode 100644 tests/templates/tests.py delete mode 100644 tests/templates/unicode.py delete mode 100644 tests/templates/urls.py delete mode 100644 tests/templates/views.py create mode 100644 tests/templates/views/article_archive_day.html create mode 100644 tests/templates/views/article_archive_month.html create mode 100644 tests/templates/views/article_confirm_delete.html create mode 100644 tests/templates/views/article_detail.html create mode 100644 tests/templates/views/article_form.html create mode 100644 tests/templates/views/article_list.html create mode 100644 tests/templates/views/datearticle_archive_month.html create mode 100644 tests/templates/views/urlarticle_detail.html create mode 100644 tests/templates/views/urlarticle_form.html delete mode 100644 tests/test_templates/base.html delete mode 100644 tests/test_templates/comments/comment_notification_email.txt delete mode 100644 tests/test_templates/custom_admin/add_form.html delete mode 100644 tests/test_templates/custom_admin/change_form.html delete mode 100644 tests/test_templates/custom_admin/change_list.html delete mode 100644 tests/test_templates/custom_admin/delete_confirmation.html delete mode 100644 tests/test_templates/custom_admin/delete_selected_confirmation.html delete mode 100644 tests/test_templates/custom_admin/index.html delete mode 100644 tests/test_templates/custom_admin/login.html delete mode 100644 tests/test_templates/custom_admin/logout.html delete mode 100644 tests/test_templates/custom_admin/object_history.html delete mode 100644 tests/test_templates/custom_admin/password_change_done.html delete mode 100644 tests/test_templates/custom_admin/password_change_form.html delete mode 100644 tests/test_templates/extended.html delete mode 100644 tests/test_templates/form_view.html delete mode 100644 tests/test_templates/login.html delete mode 100644 tests/test_templates/views/article_archive_day.html delete mode 100644 tests/test_templates/views/article_archive_month.html delete mode 100644 tests/test_templates/views/article_confirm_delete.html delete mode 100644 tests/test_templates/views/article_detail.html delete mode 100644 tests/test_templates/views/article_form.html delete mode 100644 tests/test_templates/views/article_list.html delete mode 100644 tests/test_templates/views/datearticle_archive_month.html delete mode 100644 tests/test_templates/views/urlarticle_detail.html delete mode 100644 tests/test_templates/views/urlarticle_form.html delete mode 100644 tests/utils/__init__.py delete mode 100644 tests/utils/archive.py delete mode 100644 tests/utils/archives/foobar.tar delete mode 100644 tests/utils/archives/foobar.tar.bz2 delete mode 100644 tests/utils/archives/foobar.tar.gz delete mode 100644 tests/utils/archives/foobar.zip delete mode 100644 tests/utils/baseconv.py delete mode 100644 tests/utils/checksums.py delete mode 100644 tests/utils/crypto.py delete mode 100644 tests/utils/datastructures.py delete mode 100644 tests/utils/dateformat.py delete mode 100644 tests/utils/dateparse.py delete mode 100644 tests/utils/datetime_safe.py delete mode 100644 tests/utils/decorators.py delete mode 100644 tests/utils/eggs/test_egg.egg delete mode 100644 tests/utils/encoding.py delete mode 100644 tests/utils/feedgenerator.py delete mode 100644 tests/utils/functional.py delete mode 100644 tests/utils/html.py delete mode 100644 tests/utils/http.py delete mode 100644 tests/utils/ipv6.py delete mode 100644 tests/utils/jslex.py delete mode 100644 tests/utils/models.py delete mode 100644 tests/utils/module_loading.py delete mode 100644 tests/utils/numberformat.py delete mode 100644 tests/utils/os_utils.py delete mode 100644 tests/utils/regex_helper.py delete mode 100644 tests/utils/simplelazyobject.py delete mode 100644 tests/utils/termcolors.py delete mode 100644 tests/utils/test_module/__init__.py delete mode 100644 tests/utils/test_module/bad_module.py delete mode 100644 tests/utils/test_module/good_module.py delete mode 100644 tests/utils/test_no_submodule.py delete mode 100644 tests/utils/tests.py delete mode 100644 tests/utils/text.py delete mode 100644 tests/utils/timesince.py delete mode 100644 tests/utils/timezone.py delete mode 100644 tests/utils/tzinfo.py create mode 100644 tests/utils_tests/__init__.py create mode 100644 tests/utils_tests/archive.py create mode 100644 tests/utils_tests/archives/foobar.tar create mode 100644 tests/utils_tests/archives/foobar.tar.bz2 create mode 100644 tests/utils_tests/archives/foobar.tar.gz create mode 100644 tests/utils_tests/archives/foobar.zip create mode 100644 tests/utils_tests/baseconv.py create mode 100644 tests/utils_tests/checksums.py create mode 100644 tests/utils_tests/crypto.py create mode 100644 tests/utils_tests/datastructures.py create mode 100644 tests/utils_tests/dateformat.py create mode 100644 tests/utils_tests/dateparse.py create mode 100644 tests/utils_tests/datetime_safe.py create mode 100644 tests/utils_tests/decorators.py create mode 100644 tests/utils_tests/eggs/test_egg.egg create mode 100644 tests/utils_tests/encoding.py create mode 100644 tests/utils_tests/feedgenerator.py create mode 100644 tests/utils_tests/functional.py create mode 100644 tests/utils_tests/html.py create mode 100644 tests/utils_tests/http.py create mode 100644 tests/utils_tests/ipv6.py create mode 100644 tests/utils_tests/jslex.py create mode 100644 tests/utils_tests/models.py create mode 100644 tests/utils_tests/module_loading.py create mode 100644 tests/utils_tests/numberformat.py create mode 100644 tests/utils_tests/os_utils.py create mode 100644 tests/utils_tests/regex_helper.py create mode 100644 tests/utils_tests/simplelazyobject.py create mode 100644 tests/utils_tests/termcolors.py create mode 100644 tests/utils_tests/test_module/__init__.py create mode 100644 tests/utils_tests/test_module/bad_module.py create mode 100644 tests/utils_tests/test_module/good_module.py create mode 100644 tests/utils_tests/test_no_submodule.py create mode 100644 tests/utils_tests/tests.py create mode 100644 tests/utils_tests/text.py create mode 100644 tests/utils_tests/timesince.py create mode 100644 tests/utils_tests/timezone.py create mode 100644 tests/utils_tests/tzinfo.py create mode 100644 tests/view_tests/__init__.py create mode 100644 tests/view_tests/app0/__init__.py create mode 100644 tests/view_tests/app0/locale/en/LC_MESSAGES/djangojs.mo create mode 100644 tests/view_tests/app0/locale/en/LC_MESSAGES/djangojs.po create mode 100644 tests/view_tests/app1/__init__.py create mode 100644 tests/view_tests/app1/locale/fr/LC_MESSAGES/djangojs.mo create mode 100644 tests/view_tests/app1/locale/fr/LC_MESSAGES/djangojs.po create mode 100644 tests/view_tests/app2/__init__.py create mode 100644 tests/view_tests/app2/locale/fr/LC_MESSAGES/djangojs.mo create mode 100644 tests/view_tests/app2/locale/fr/LC_MESSAGES/djangojs.po create mode 100644 tests/view_tests/app3/__init__.py create mode 100644 tests/view_tests/app3/locale/es_AR/LC_MESSAGES/djangojs.mo create mode 100644 tests/view_tests/app3/locale/es_AR/LC_MESSAGES/djangojs.po create mode 100644 tests/view_tests/app4/__init__.py create mode 100644 tests/view_tests/app4/locale/es_AR/LC_MESSAGES/djangojs.mo create mode 100644 tests/view_tests/app4/locale/es_AR/LC_MESSAGES/djangojs.po create mode 100644 tests/view_tests/fixtures/testdata.json create mode 100644 tests/view_tests/generic_urls.py create mode 100644 tests/view_tests/locale/de/LC_MESSAGES/djangojs.mo create mode 100644 tests/view_tests/locale/de/LC_MESSAGES/djangojs.po create mode 100644 tests/view_tests/locale/es/LC_MESSAGES/djangojs.mo create mode 100644 tests/view_tests/locale/es/LC_MESSAGES/djangojs.po create mode 100644 tests/view_tests/locale/fr/LC_MESSAGES/djangojs.mo create mode 100644 tests/view_tests/locale/fr/LC_MESSAGES/djangojs.po create mode 100644 tests/view_tests/locale/ru/LC_MESSAGES/djangojs.mo create mode 100644 tests/view_tests/locale/ru/LC_MESSAGES/djangojs.po create mode 100644 tests/view_tests/media/file.txt create mode 100644 tests/view_tests/media/file.txt.gz create mode 100644 tests/view_tests/media/file.unknown create mode 100644 tests/view_tests/models.py create mode 100644 tests/view_tests/templates/debug/render_test.html create mode 100644 tests/view_tests/templates/debug/template_exception.html create mode 100644 tests/view_tests/templates/jsi18n.html create mode 100644 tests/view_tests/templatetags/__init__.py create mode 100644 tests/view_tests/templatetags/debugtags.py create mode 100644 tests/view_tests/tests/__init__.py create mode 100644 tests/view_tests/tests/debug.py create mode 100644 tests/view_tests/tests/defaults.py create mode 100644 tests/view_tests/tests/i18n.py create mode 100644 tests/view_tests/tests/shortcuts.py create mode 100644 tests/view_tests/tests/specials.py create mode 100644 tests/view_tests/tests/static.py create mode 100644 tests/view_tests/urls.py create mode 100644 tests/view_tests/views.py delete mode 100644 tests/views/__init__.py delete mode 100644 tests/views/app0/__init__.py delete mode 100644 tests/views/app0/locale/en/LC_MESSAGES/djangojs.mo delete mode 100644 tests/views/app0/locale/en/LC_MESSAGES/djangojs.po delete mode 100644 tests/views/app1/__init__.py delete mode 100644 tests/views/app1/locale/fr/LC_MESSAGES/djangojs.mo delete mode 100644 tests/views/app1/locale/fr/LC_MESSAGES/djangojs.po delete mode 100644 tests/views/app2/__init__.py delete mode 100644 tests/views/app2/locale/fr/LC_MESSAGES/djangojs.mo delete mode 100644 tests/views/app2/locale/fr/LC_MESSAGES/djangojs.po delete mode 100644 tests/views/app3/__init__.py delete mode 100644 tests/views/app3/locale/es_AR/LC_MESSAGES/djangojs.mo delete mode 100644 tests/views/app3/locale/es_AR/LC_MESSAGES/djangojs.po delete mode 100644 tests/views/app4/__init__.py delete mode 100644 tests/views/app4/locale/es_AR/LC_MESSAGES/djangojs.mo delete mode 100644 tests/views/app4/locale/es_AR/LC_MESSAGES/djangojs.po delete mode 100644 tests/views/fixtures/testdata.json delete mode 100644 tests/views/generic_urls.py delete mode 100644 tests/views/locale/de/LC_MESSAGES/djangojs.mo delete mode 100644 tests/views/locale/de/LC_MESSAGES/djangojs.po delete mode 100644 tests/views/locale/es/LC_MESSAGES/djangojs.mo delete mode 100644 tests/views/locale/es/LC_MESSAGES/djangojs.po delete mode 100644 tests/views/locale/fr/LC_MESSAGES/djangojs.mo delete mode 100644 tests/views/locale/fr/LC_MESSAGES/djangojs.po delete mode 100644 tests/views/locale/ru/LC_MESSAGES/djangojs.mo delete mode 100644 tests/views/locale/ru/LC_MESSAGES/djangojs.po delete mode 100644 tests/views/media/file.txt delete mode 100644 tests/views/media/file.txt.gz delete mode 100644 tests/views/media/file.unknown delete mode 100644 tests/views/models.py delete mode 100644 tests/views/templates/debug/render_test.html delete mode 100644 tests/views/templates/debug/template_exception.html delete mode 100644 tests/views/templates/jsi18n.html delete mode 100644 tests/views/templatetags/__init__.py delete mode 100644 tests/views/templatetags/debugtags.py delete mode 100644 tests/views/tests/__init__.py delete mode 100644 tests/views/tests/debug.py delete mode 100644 tests/views/tests/defaults.py delete mode 100644 tests/views/tests/i18n.py delete mode 100644 tests/views/tests/shortcuts.py delete mode 100644 tests/views/tests/specials.py delete mode 100644 tests/views/tests/static.py delete mode 100644 tests/views/urls.py delete mode 100644 tests/views/views.py (limited to 'tests/admin_scripts/tests.py') diff --git a/tests/admin_changelist/tests.py b/tests/admin_changelist/tests.py index 7a3a5c0e03..bb39f22411 100644 --- a/tests/admin_changelist/tests.py +++ b/tests/admin_changelist/tests.py @@ -24,7 +24,7 @@ from .models import (Event, Child, Parent, Genre, Band, Musician, Group, class ChangeListTests(TestCase): - urls = "regressiontests.admin_changelist.urls" + urls = "admin_changelist.urls" def setUp(self): self.factory = RequestFactory() diff --git a/tests/admin_inlines/tests.py b/tests/admin_inlines/tests.py index 7d00ea40de..91962bd821 100644 --- a/tests/admin_inlines/tests.py +++ b/tests/admin_inlines/tests.py @@ -17,7 +17,7 @@ from .models import (Holder, Inner, Holder2, Inner2, Holder3, Inner3, Person, @override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',)) class TestInline(TestCase): - urls = "regressiontests.admin_inlines.urls" + urls = "admin_inlines.urls" fixtures = ['admin-views-users.xml'] def setUp(self): @@ -196,7 +196,7 @@ class TestInline(TestCase): @override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',)) class TestInlineMedia(TestCase): - urls = "regressiontests.admin_inlines.urls" + urls = "admin_inlines.urls" fixtures = ['admin-views-users.xml'] def setUp(self): @@ -233,7 +233,7 @@ class TestInlineMedia(TestCase): self.assertContains(response, 'my_awesome_inline_scripts.js') class TestInlineAdminForm(TestCase): - urls = "regressiontests.admin_inlines.urls" + urls = "admin_inlines.urls" def test_immutable_content_type(self): """Regression for #9362 @@ -256,7 +256,7 @@ class TestInlinePermissions(TestCase): inline. Refs #8060. """ - urls = "regressiontests.admin_inlines.urls" + urls = "admin_inlines.urls" def setUp(self): self.user = User(username='admin') @@ -451,7 +451,7 @@ class TestInlinePermissions(TestCase): class SeleniumFirefoxTests(AdminSeleniumWebDriverTestCase): webdriver_class = 'selenium.webdriver.firefox.webdriver.WebDriver' fixtures = ['admin-views-users.xml'] - urls = "regressiontests.admin_inlines.urls" + urls = "admin_inlines.urls" def test_add_stackeds(self): """ diff --git a/tests/admin_scripts/tests.py b/tests/admin_scripts/tests.py index 921108600e..e96bd440cf 100644 --- a/tests/admin_scripts/tests.py +++ b/tests/admin_scripts/tests.py @@ -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) diff --git a/tests/admin_validation/tests.py b/tests/admin_validation/tests.py index b9b42c6bb9..5b2c45f6f2 100644 --- a/tests/admin_validation/tests.py +++ b/tests/admin_validation/tests.py @@ -142,7 +142,7 @@ class ValidationTestCase(TestCase): model = TwoAlbumFKAndAnE self.assertRaisesMessage(Exception, - " has more than 1 ForeignKey to ", + " has more than 1 ForeignKey to ", validate_inline, TwoAlbumFKAndAnEInline, None, Album) diff --git a/tests/admin_views/tests.py b/tests/admin_views/tests.py index d3cfaa3e24..0bcfc0c034 100644 --- a/tests/admin_views/tests.py +++ b/tests/admin_views/tests.py @@ -64,7 +64,7 @@ class AdminViewBasicTest(TestCase): # this test case and changing urlbit. urlbit = 'admin' - urls = "regressiontests.admin_views.urls" + urls = "admin_views.urls" def setUp(self): self.old_USE_I18N = settings.USE_I18N @@ -610,7 +610,7 @@ class AdminViewBasicTest(TestCase): @override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',)) class AdminViewFormUrlTest(TestCase): - urls = "regressiontests.admin_views.urls" + urls = "admin_views.urls" fixtures = ["admin-views-users.xml"] urlbit = "admin3" @@ -644,7 +644,7 @@ class AdminViewFormUrlTest(TestCase): class AdminJavaScriptTest(TestCase): fixtures = ['admin-views-users.xml'] - urls = "regressiontests.admin_views.urls" + urls = "admin_views.urls" def setUp(self): self.client.login(username='super', password='secret') @@ -709,7 +709,7 @@ class AdminJavaScriptTest(TestCase): @override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',)) class SaveAsTests(TestCase): - urls = "regressiontests.admin_views.urls" + urls = "admin_views.urls" fixtures = ['admin-views-users.xml', 'admin-views-person.xml'] def setUp(self): @@ -739,7 +739,7 @@ class SaveAsTests(TestCase): class CustomModelAdminTest(AdminViewBasicTest): - urls = "regressiontests.admin_views.urls" + urls = "admin_views.urls" urlbit = "admin2" def testCustomAdminSiteLoginForm(self): @@ -816,7 +816,7 @@ def get_perm(Model, perm): class AdminViewPermissionsTest(TestCase): """Tests for Admin Views Permissions.""" - urls = "regressiontests.admin_views.urls" + urls = "admin_views.urls" fixtures = ['admin-views-users.xml'] def setUp(self): @@ -1257,7 +1257,7 @@ class AdminViewPermissionsTest(TestCase): class AdminViewsNoUrlTest(TestCase): """Regression test for #17333""" - urls = "regressiontests.admin_views.urls" + urls = "admin_views.urls" fixtures = ['admin-views-users.xml'] def setUp(self): @@ -1287,7 +1287,7 @@ class AdminViewsNoUrlTest(TestCase): @override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',)) class AdminViewDeletedObjectsTest(TestCase): - urls = "regressiontests.admin_views.urls" + urls = "admin_views.urls" fixtures = ['admin-views-users.xml', 'deleted-objects.xml'] def setUp(self): @@ -1405,7 +1405,7 @@ class AdminViewDeletedObjectsTest(TestCase): @override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',)) class AdminViewStringPrimaryKeyTest(TestCase): - urls = "regressiontests.admin_views.urls" + urls = "admin_views.urls" fixtures = ['admin-views-users.xml', 'string-primary-key.xml'] def __init__(self, *args): @@ -1526,7 +1526,7 @@ class AdminViewStringPrimaryKeyTest(TestCase): @override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',)) class SecureViewTests(TestCase): - urls = "regressiontests.admin_views.urls" + urls = "admin_views.urls" fixtures = ['admin-views-users.xml'] def setUp(self): @@ -1686,7 +1686,7 @@ class SecureViewTests(TestCase): @override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',)) class AdminViewUnicodeTest(TestCase): - urls = "regressiontests.admin_views.urls" + urls = "admin_views.urls" fixtures = ['admin-views-unicode.xml'] def setUp(self): @@ -1741,7 +1741,7 @@ class AdminViewUnicodeTest(TestCase): @override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',)) class AdminViewListEditable(TestCase): - urls = "regressiontests.admin_views.urls" + urls = "admin_views.urls" fixtures = ['admin-views-users.xml', 'admin-views-person.xml'] def setUp(self): @@ -2118,7 +2118,7 @@ class AdminViewListEditable(TestCase): @override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',)) class AdminSearchTest(TestCase): - urls = "regressiontests.admin_views.urls" + urls = "admin_views.urls" fixtures = ['admin-views-users', 'multiple-child-classes', 'admin-views-person'] @@ -2166,7 +2166,7 @@ class AdminSearchTest(TestCase): @override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',)) class AdminInheritedInlinesTest(TestCase): - urls = "regressiontests.admin_views.urls" + urls = "admin_views.urls" fixtures = ['admin-views-users.xml'] def setUp(self): @@ -2254,7 +2254,7 @@ class AdminInheritedInlinesTest(TestCase): @override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',)) class AdminActionsTest(TestCase): - urls = "regressiontests.admin_views.urls" + urls = "admin_views.urls" fixtures = ['admin-views-users.xml', 'admin-views-actions.xml'] def setUp(self): @@ -2473,7 +2473,7 @@ class AdminActionsTest(TestCase): @override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',)) class TestCustomChangeList(TestCase): - urls = "regressiontests.admin_views.urls" + urls = "admin_views.urls" fixtures = ['admin-views-users.xml'] urlbit = 'admin' @@ -2502,7 +2502,7 @@ class TestCustomChangeList(TestCase): @override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',)) class TestInlineNotEditable(TestCase): - urls = "regressiontests.admin_views.urls" + urls = "admin_views.urls" fixtures = ['admin-views-users.xml'] def setUp(self): @@ -2522,7 +2522,7 @@ class TestInlineNotEditable(TestCase): @override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',)) class AdminCustomQuerysetTest(TestCase): - urls = "regressiontests.admin_views.urls" + urls = "admin_views.urls" fixtures = ['admin-views-users.xml'] def setUp(self): @@ -2748,7 +2748,7 @@ class AdminCustomQuerysetTest(TestCase): @override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',)) class AdminInlineFileUploadTest(TestCase): - urls = "regressiontests.admin_views.urls" + urls = "admin_views.urls" fixtures = ['admin-views-users.xml', 'admin-views-actions.xml'] urlbit = 'admin' @@ -2795,7 +2795,7 @@ class AdminInlineFileUploadTest(TestCase): @override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',)) class AdminInlineTests(TestCase): - urls = "regressiontests.admin_views.urls" + urls = "admin_views.urls" fixtures = ['admin-views-users.xml'] def setUp(self): @@ -3114,7 +3114,7 @@ class AdminInlineTests(TestCase): @override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',)) class NeverCacheTests(TestCase): - urls = "regressiontests.admin_views.urls" + urls = "admin_views.urls" fixtures = ['admin-views-users.xml', 'admin-views-colors.xml', 'admin-views-fabrics.xml'] def setUp(self): @@ -3188,7 +3188,7 @@ class NeverCacheTests(TestCase): @override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',)) class PrePopulatedTest(TestCase): - urls = "regressiontests.admin_views.urls" + urls = "admin_views.urls" fixtures = ['admin-views-users.xml'] def setUp(self): @@ -3225,7 +3225,7 @@ class PrePopulatedTest(TestCase): @override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',)) class SeleniumAdminViewsFirefoxTests(AdminSeleniumWebDriverTestCase): webdriver_class = 'selenium.webdriver.firefox.webdriver.WebDriver' - urls = "regressiontests.admin_views.urls" + urls = "admin_views.urls" fixtures = ['admin-views-users.xml'] def test_prepopulated_fields(self): @@ -3356,7 +3356,7 @@ class SeleniumAdminViewsIETests(SeleniumAdminViewsFirefoxTests): @override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',)) class ReadonlyTest(TestCase): - urls = "regressiontests.admin_views.urls" + urls = "admin_views.urls" fixtures = ['admin-views-users.xml'] def setUp(self): @@ -3444,7 +3444,7 @@ class ReadonlyTest(TestCase): @override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',)) class RawIdFieldsTest(TestCase): - urls = "regressiontests.admin_views.urls" + urls = "admin_views.urls" fixtures = ['admin-views-users.xml'] def setUp(self): @@ -3482,7 +3482,7 @@ class UserAdminTest(TestCase): """ Tests user CRUD functionality. """ - urls = "regressiontests.admin_views.urls" + urls = "admin_views.urls" fixtures = ['admin-views-users.xml'] def setUp(self): @@ -3583,7 +3583,7 @@ class GroupAdminTest(TestCase): """ Tests group CRUD functionality. """ - urls = "regressiontests.admin_views.urls" + urls = "admin_views.urls" fixtures = ['admin-views-users.xml'] def setUp(self): @@ -3612,7 +3612,7 @@ class GroupAdminTest(TestCase): @override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',)) class CSSTest(TestCase): - urls = "regressiontests.admin_views.urls" + urls = "admin_views.urls" fixtures = ['admin-views-users.xml'] def setUp(self): @@ -3668,7 +3668,7 @@ except ImportError: @unittest.skipUnless(docutils, "no docutils installed.") @override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',)) class AdminDocsTest(TestCase): - urls = "regressiontests.admin_views.urls" + urls = "admin_views.urls" fixtures = ['admin-views-users.xml'] def setUp(self): @@ -3711,7 +3711,7 @@ class AdminDocsTest(TestCase): @override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',)) class ValidXHTMLTests(TestCase): - urls = "regressiontests.admin_views.urls" + urls = "admin_views.urls" fixtures = ['admin-views-users.xml'] urlbit = 'admin' @@ -3735,7 +3735,7 @@ class ValidXHTMLTests(TestCase): @override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',)) class DateHierarchyTests(TestCase): - urls = "regressiontests.admin_views.urls" + urls = "admin_views.urls" fixtures = ['admin-views-users.xml'] def setUp(self): @@ -3867,7 +3867,7 @@ class AdminCustomSaveRelatedTests(TestCase): Ensure that one can easily customize the way related objects are saved. Refs #16115. """ - urls = "regressiontests.admin_views.urls" + urls = "admin_views.urls" fixtures = ['admin-views-users.xml'] def setUp(self): @@ -3932,7 +3932,7 @@ class AdminCustomSaveRelatedTests(TestCase): @override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',)) class AdminViewLogoutTest(TestCase): - urls = "regressiontests.admin_views.urls" + urls = "admin_views.urls" fixtures = ['admin-views-users.xml'] def setUp(self): @@ -3961,7 +3961,7 @@ class AdminViewLogoutTest(TestCase): @override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.SHA1PasswordHasher',)) class AdminUserMessageTest(TestCase): - urls = "regressiontests.admin_views.urls" + urls = "admin_views.urls" fixtures = ['admin-views-users.xml'] def setUp(self): diff --git a/tests/admin_widgets/tests.py b/tests/admin_widgets/tests.py index d559b53531..4e09922893 100644 --- a/tests/admin_widgets/tests.py +++ b/tests/admin_widgets/tests.py @@ -460,7 +460,7 @@ class RelatedFieldWidgetWrapperTests(DjangoTestCase): class DateTimePickerSeleniumFirefoxTests(AdminSeleniumWebDriverTestCase): webdriver_class = 'selenium.webdriver.firefox.webdriver.WebDriver' fixtures = ['admin-widgets-users.xml'] - urls = "regressiontests.admin_widgets.urls" + urls = "admin_widgets.urls" def test_show_hide_date_time_picker_widgets(self): """ @@ -516,7 +516,7 @@ class DateTimePickerSeleniumIETests(DateTimePickerSeleniumFirefoxTests): class HorizontalVerticalFilterSeleniumFirefoxTests(AdminSeleniumWebDriverTestCase): webdriver_class = 'selenium.webdriver.firefox.webdriver.WebDriver' fixtures = ['admin-widgets-users.xml'] - urls = "regressiontests.admin_widgets.urls" + urls = "admin_widgets.urls" def setUp(self): self.lisa = models.Student.objects.create(name='Lisa') diff --git a/tests/cache/tests.py b/tests/cache/tests.py index 24e510c5d2..c1b68ec809 100644 --- a/tests/cache/tests.py +++ b/tests/cache/tests.py @@ -809,7 +809,7 @@ class DBCacheTests(BaseCacheTests, TransactionTestCase): self.prefix_cache = get_cache(self.backend_name, LOCATION=self._table_name, KEY_PREFIX='cacheprefix') self.v2_cache = get_cache(self.backend_name, LOCATION=self._table_name, VERSION=2) self.custom_key_cache = get_cache(self.backend_name, LOCATION=self._table_name, KEY_FUNCTION=custom_key_func) - self.custom_key_cache2 = get_cache(self.backend_name, LOCATION=self._table_name, KEY_FUNCTION='regressiontests.cache.tests.custom_key_func') + self.custom_key_cache2 = get_cache(self.backend_name, LOCATION=self._table_name, KEY_FUNCTION='cache.tests.custom_key_func') def tearDown(self): from django.db import connection @@ -897,7 +897,7 @@ class LocMemCacheTests(unittest.TestCase, BaseCacheTests): self.prefix_cache = get_cache(self.backend_name, KEY_PREFIX='cacheprefix') self.v2_cache = get_cache(self.backend_name, VERSION=2) self.custom_key_cache = get_cache(self.backend_name, OPTIONS={'MAX_ENTRIES': 30}, KEY_FUNCTION=custom_key_func) - self.custom_key_cache2 = get_cache(self.backend_name, OPTIONS={'MAX_ENTRIES': 30}, KEY_FUNCTION='regressiontests.cache.tests.custom_key_func') + self.custom_key_cache2 = get_cache(self.backend_name, OPTIONS={'MAX_ENTRIES': 30}, KEY_FUNCTION='cache.tests.custom_key_func') # LocMem requires a hack to make the other caches # share a data store with the 'normal' cache. @@ -966,7 +966,7 @@ class MemcachedCacheTests(unittest.TestCase, BaseCacheTests): self.prefix_cache = get_cache(cache_key, KEY_PREFIX=random_prefix) self.v2_cache = get_cache(cache_key, VERSION=2) self.custom_key_cache = get_cache(cache_key, KEY_FUNCTION=custom_key_func) - self.custom_key_cache2 = get_cache(cache_key, KEY_FUNCTION='regressiontests.cache.tests.custom_key_func') + self.custom_key_cache2 = get_cache(cache_key, KEY_FUNCTION='cache.tests.custom_key_func') def tearDown(self): self.cache.clear() @@ -1011,7 +1011,7 @@ class FileBasedCacheTests(unittest.TestCase, BaseCacheTests): self.prefix_cache = get_cache(self.backend_name, LOCATION=self.dirname, KEY_PREFIX='cacheprefix') self.v2_cache = get_cache(self.backend_name, LOCATION=self.dirname, VERSION=2) self.custom_key_cache = get_cache(self.backend_name, LOCATION=self.dirname, KEY_FUNCTION=custom_key_func) - self.custom_key_cache2 = get_cache(self.backend_name, LOCATION=self.dirname, KEY_FUNCTION='regressiontests.cache.tests.custom_key_func') + self.custom_key_cache2 = get_cache(self.backend_name, LOCATION=self.dirname, KEY_FUNCTION='cache.tests.custom_key_func') def tearDown(self): self.cache.clear() @@ -1055,7 +1055,7 @@ class CustomCacheKeyValidationTests(unittest.TestCase): """ def test_custom_key_validation(self): - cache = get_cache('regressiontests.cache.liberal_backend://') + cache = get_cache('cache.liberal_backend://') # this key is both longer than 250 characters, and has spaces key = 'some key with spaces' * 15 @@ -1082,7 +1082,7 @@ class GetCacheTests(unittest.TestCase): def test_close(self): from django.core import signals - cache = get_cache('regressiontests.cache.closeable_cache.CacheClass') + cache = get_cache('cache.closeable_cache.CacheClass') self.assertFalse(cache.closed) signals.request_finished.send(self.__class__) self.assertTrue(cache.closed) @@ -1865,7 +1865,7 @@ class TestWithTemplateResponse(TestCase): class TestEtagWithAdmin(TestCase): # See https://code.djangoproject.com/ticket/16003 - urls = "regressiontests.admin_views.urls" + urls = "admin_views.urls" def test_admin(self): with self.settings(USE_ETAGS=False): diff --git a/tests/commands_sql/tests.py b/tests/commands_sql/tests.py index 949032ae6f..831e9a27c4 100644 --- a/tests/commands_sql/tests.py +++ b/tests/commands_sql/tests.py @@ -7,7 +7,7 @@ from django.db import connections, DEFAULT_DB_ALIAS, models from django.test import TestCase from django.utils import six -# See also regressiontests/initial_sql_regress for 'custom_sql_for_model' tests +# See also initial_sql_regress for 'custom_sql_for_model' tests class SQLCommandsTestCase(TestCase): diff --git a/tests/comment_tests/custom_comments/__init__.py b/tests/comment_tests/custom_comments/__init__.py index 598927eace..14c614f610 100644 --- a/tests/comment_tests/custom_comments/__init__.py +++ b/tests/comment_tests/custom_comments/__init__.py @@ -1,32 +1,32 @@ from django.core import urlresolvers -from regressiontests.comment_tests.custom_comments.models import CustomComment -from regressiontests.comment_tests.custom_comments.forms import CustomCommentForm +from comment_tests.custom_comments.models import CustomComment +from comment_tests.custom_comments.forms import CustomCommentForm def get_model(): - return CustomComment + return CustomComment def get_form(): return CustomCommentForm def get_form_target(): return urlresolvers.reverse( - "regressiontests.comment_tests.custom_comments.views.custom_submit_comment" + "comment_tests.custom_comments.views.custom_submit_comment" ) def get_flag_url(c): return urlresolvers.reverse( - "regressiontests.comment_tests.custom_comments.views.custom_flag_comment", + "comment_tests.custom_comments.views.custom_flag_comment", args=(c.id,) ) def get_delete_url(c): return urlresolvers.reverse( - "regressiontests.comment_tests.custom_comments.views.custom_delete_comment", + "comment_tests.custom_comments.views.custom_delete_comment", args=(c.id,) ) def get_approve_url(c): return urlresolvers.reverse( - "regressiontests.comment_tests.custom_comments.views.custom_approve_comment", + "comment_tests.custom_comments.views.custom_approve_comment", args=(c.id,) ) diff --git a/tests/comment_tests/tests/__init__.py b/tests/comment_tests/tests/__init__.py index f80b29e17b..d959dab243 100644 --- a/tests/comment_tests/tests/__init__.py +++ b/tests/comment_tests/tests/__init__.py @@ -17,7 +17,7 @@ CT = ContentType.objects.get_for_model @override_settings(PASSWORD_HASHERS=('django.contrib.auth.hashers.UnsaltedMD5PasswordHasher',)) class CommentTestCase(TestCase): fixtures = ["comment_tests"] - urls = 'regressiontests.comment_tests.urls_default' + urls = 'comment_tests.urls_default' def createSomeComments(self): # Two anonymous comments on two different objects @@ -85,11 +85,11 @@ class CommentTestCase(TestCase): d.update(f.initial) return d -from regressiontests.comment_tests.tests.app_api_tests import * -from regressiontests.comment_tests.tests.feed_tests import * -from regressiontests.comment_tests.tests.model_tests import * -from regressiontests.comment_tests.tests.comment_form_tests import * -from regressiontests.comment_tests.tests.templatetag_tests import * -from regressiontests.comment_tests.tests.comment_view_tests import * -from regressiontests.comment_tests.tests.moderation_view_tests import * -from regressiontests.comment_tests.tests.comment_utils_moderators_tests import * +from comment_tests.tests.app_api_tests import * +from comment_tests.tests.feed_tests import * +from comment_tests.tests.model_tests import * +from comment_tests.tests.comment_form_tests import * +from comment_tests.tests.templatetag_tests import * +from comment_tests.tests.comment_view_tests import * +from comment_tests.tests.moderation_view_tests import * +from comment_tests.tests.comment_utils_moderators_tests import * diff --git a/tests/comment_tests/tests/app_api_tests.py b/tests/comment_tests/tests/app_api_tests.py index a756068790..ed23ba39cc 100644 --- a/tests/comment_tests/tests/app_api_tests.py +++ b/tests/comment_tests/tests/app_api_tests.py @@ -45,23 +45,23 @@ class CommentAppAPITests(CommentTestCase): @override_settings( - COMMENTS_APP='regressiontests.comment_tests.custom_comments', + COMMENTS_APP='comment_tests.custom_comments', INSTALLED_APPS=list(settings.INSTALLED_APPS) + [ - 'regressiontests.comment_tests.custom_comments'], + 'comment_tests.custom_comments'], ) class CustomCommentTest(CommentTestCase): - urls = 'regressiontests.comment_tests.urls' + urls = 'comment_tests.urls' def testGetCommentApp(self): - from regressiontests.comment_tests import custom_comments + from comment_tests import custom_comments self.assertEqual(comments.get_comment_app(), custom_comments) def testGetModel(self): - from regressiontests.comment_tests.custom_comments.models import CustomComment + from comment_tests.custom_comments.models import CustomComment self.assertEqual(comments.get_model(), CustomComment) def testGetForm(self): - from regressiontests.comment_tests.custom_comments.forms import CustomCommentForm + from comment_tests.custom_comments.forms import CustomCommentForm self.assertEqual(comments.get_form(), CustomCommentForm) def testGetFormTarget(self): diff --git a/tests/comment_tests/tests/feed_tests.py b/tests/comment_tests/tests/feed_tests.py index c93d7abf7d..941ffb6bf2 100644 --- a/tests/comment_tests/tests/feed_tests.py +++ b/tests/comment_tests/tests/feed_tests.py @@ -12,7 +12,7 @@ from ..models import Article class CommentFeedTests(CommentTestCase): - urls = 'regressiontests.comment_tests.urls' + urls = 'comment_tests.urls' feed_url = '/rss/comments/' def setUp(self): diff --git a/tests/comment_tests/tests/moderation_view_tests.py b/tests/comment_tests/tests/moderation_view_tests.py index c932fed2d2..02af35cfe4 100644 --- a/tests/comment_tests/tests/moderation_view_tests.py +++ b/tests/comment_tests/tests/moderation_view_tests.py @@ -252,7 +252,7 @@ class ApproveViewTests(CommentTestCase): self.assertTemplateUsed(response, "comments/approved.html") class AdminActionsTests(CommentTestCase): - urls = "regressiontests.comment_tests.urls_admin" + urls = "comment_tests.urls_admin" def setUp(self): super(AdminActionsTests, self).setUp() diff --git a/tests/conditional_processing/models.py b/tests/conditional_processing/models.py index b47fdf6fb5..77f1ff54ed 100644 --- a/tests/conditional_processing/models.py +++ b/tests/conditional_processing/models.py @@ -16,7 +16,7 @@ ETAG = 'b4246ffc4f62314ca13147c9d4f76974' EXPIRED_ETAG = '7fae4cd4b0f81e7d2914700043aa8ed6' class ConditionalGet(TestCase): - urls = 'regressiontests.conditional_processing.urls' + urls = 'conditional_processing.urls' def assertFullResponse(self, response, check_last_modified=True, check_etag=True): self.assertEqual(response.status_code, 200) diff --git a/tests/context_processors/tests.py b/tests/context_processors/tests.py index 1f2209efb0..c57c592de6 100644 --- a/tests/context_processors/tests.py +++ b/tests/context_processors/tests.py @@ -9,7 +9,7 @@ class RequestContextProcessorTests(TestCase): Tests for the ``django.core.context_processors.request`` processor. """ - urls = 'regressiontests.context_processors.urls' + urls = 'context_processors.urls' def test_request_attributes(self): """ diff --git a/tests/empty/no_models/tests.py b/tests/empty/no_models/tests.py index 6292ca9f74..8b8db1af39 100644 --- a/tests/empty/no_models/tests.py +++ b/tests/empty/no_models/tests.py @@ -2,5 +2,5 @@ from django.test import TestCase class NoModelTests(TestCase): - """ A placeholder test case. See modeltests.empty.tests for more info. """ + """ A placeholder test case. See empty.tests for more info. """ pass diff --git a/tests/empty/tests.py b/tests/empty/tests.py index 4c0c4409d8..6dd9f7c75d 100644 --- a/tests/empty/tests.py +++ b/tests/empty/tests.py @@ -31,7 +31,7 @@ class NoModelTests(TestCase): It seemed like an appropriate home for it. """ - @override_settings(INSTALLED_APPS=("modeltests.empty.no_models",)) + @override_settings(INSTALLED_APPS=("empty.no_models",)) def test_no_models(self): with six.assertRaisesRegex(self, ImproperlyConfigured, 'App with label no_models is missing a models.py module.'): diff --git a/tests/file_storage/tests.py b/tests/file_storage/tests.py index 7754eb2821..5e6adee894 100644 --- a/tests/file_storage/tests.py +++ b/tests/file_storage/tests.py @@ -27,7 +27,7 @@ from django.utils import six from django.utils import unittest from django.utils._os import upath from django.test.utils import override_settings -from ..servers.tests import LiveServerBase +from servers.tests import LiveServerBase # Try to import PIL in either of the two ways it can end up installed. # Checking for the existence of Image is enough for CPython, but diff --git a/tests/forms/__init__.py b/tests/forms/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/tests/forms/models.py b/tests/forms/models.py deleted file mode 100644 index bec31d12d7..0000000000 --- a/tests/forms/models.py +++ /dev/null @@ -1,90 +0,0 @@ -# -*- coding: utf-8 -*- -from __future__ import unicode_literals - -import os -import datetime -import tempfile - -from django.core.files.storage import FileSystemStorage -from django.db import models -from django.utils.encoding import python_2_unicode_compatible - - -temp_storage_location = tempfile.mkdtemp(dir=os.environ['DJANGO_TEST_TEMP_DIR']) -temp_storage = FileSystemStorage(location=temp_storage_location) - - -class BoundaryModel(models.Model): - positive_integer = models.PositiveIntegerField(null=True, blank=True) - - -callable_default_value = 0 -def callable_default(): - global callable_default_value - callable_default_value = callable_default_value + 1 - return callable_default_value - - -class Defaults(models.Model): - name = models.CharField(max_length=255, default='class default value') - def_date = models.DateField(default = datetime.date(1980, 1, 1)) - value = models.IntegerField(default=42) - callable_default = models.IntegerField(default=callable_default) - - -class ChoiceModel(models.Model): - """For ModelChoiceField and ModelMultipleChoiceField tests.""" - name = models.CharField(max_length=10) - - -@python_2_unicode_compatible -class ChoiceOptionModel(models.Model): - """Destination for ChoiceFieldModel's ForeignKey. - Can't reuse ChoiceModel because error_message tests require that it have no instances.""" - name = models.CharField(max_length=10) - - class Meta: - ordering = ('name',) - - def __str__(self): - return 'ChoiceOption %d' % self.pk - - -class ChoiceFieldModel(models.Model): - """Model with ForeignKey to another model, for testing ModelForm - generation with ModelChoiceField.""" - choice = models.ForeignKey(ChoiceOptionModel, blank=False, - default=lambda: ChoiceOptionModel.objects.get(name='default')) - choice_int = models.ForeignKey(ChoiceOptionModel, blank=False, related_name='choice_int', - default=lambda: 1) - - multi_choice = models.ManyToManyField(ChoiceOptionModel, blank=False, related_name='multi_choice', - default=lambda: ChoiceOptionModel.objects.filter(name='default')) - multi_choice_int = models.ManyToManyField(ChoiceOptionModel, blank=False, related_name='multi_choice_int', - default=lambda: [1]) - -class OptionalMultiChoiceModel(models.Model): - multi_choice = models.ManyToManyField(ChoiceOptionModel, blank=False, related_name='not_relevant', - default=lambda: ChoiceOptionModel.objects.filter(name='default')) - multi_choice_optional = models.ManyToManyField(ChoiceOptionModel, blank=True, null=True, - related_name='not_relevant2') - - -class FileModel(models.Model): - file = models.FileField(storage=temp_storage, upload_to='tests') - - -@python_2_unicode_compatible -class Group(models.Model): - name = models.CharField(max_length=10) - - def __str__(self): - return '%s' % self.name - - -class Cheese(models.Model): - name = models.CharField(max_length=100) - - -class Article(models.Model): - content = models.TextField() diff --git a/tests/forms/templates/forms/article_form.html b/tests/forms/templates/forms/article_form.html deleted file mode 100644 index cde85051f6..0000000000 --- a/tests/forms/templates/forms/article_form.html +++ /dev/null @@ -1,8 +0,0 @@ - - -
- {{ form.as_p }}
- -
- - diff --git a/tests/forms/tests/__init__.py b/tests/forms/tests/__init__.py deleted file mode 100644 index 6708e54c79..0000000000 --- a/tests/forms/tests/__init__.py +++ /dev/null @@ -1,21 +0,0 @@ -from __future__ import absolute_import - -from .error_messages import (FormsErrorMessagesTestCase, - ModelChoiceFieldErrorMessagesTestCase) -from .extra import FormsExtraTestCase, FormsExtraL10NTestCase -from .fields import FieldsTests -from .forms import FormsTestCase -from .formsets import (FormsFormsetTestCase, FormsetAsFooTests, - TestIsBoundBehavior, TestEmptyFormSet) -from .input_formats import (LocalizedTimeTests, CustomTimeInputFormatsTests, - SimpleTimeFormatTests, LocalizedDateTests, CustomDateInputFormatsTests, - SimpleDateFormatTests, LocalizedDateTimeTests, - CustomDateTimeInputFormatsTests, SimpleDateTimeFormatTests) -from .media import FormsMediaTestCase, StaticFormsMediaTestCase -from .models import (TestTicket12510, ModelFormCallableModelDefault, - FormsModelTestCase, RelatedModelFormTests) -from .regressions import FormsRegressionsTestCase -from .util import FormsUtilTestCase -from .validators import TestFieldWithValidators -from .widgets import (FormsWidgetTestCase, FormsI18NWidgetsTestCase, - WidgetTests, LiveWidgetTests, ClearableFileInputTests) diff --git a/tests/forms/tests/error_messages.py b/tests/forms/tests/error_messages.py deleted file mode 100644 index b76e122bc0..0000000000 --- a/tests/forms/tests/error_messages.py +++ /dev/null @@ -1,263 +0,0 @@ -# -*- coding: utf-8 -*- -from __future__ import absolute_import, unicode_literals - -from django.core.files.uploadedfile import SimpleUploadedFile -from django.forms import * -from django.test import TestCase -from django.utils.safestring import mark_safe -from django.utils.encoding import python_2_unicode_compatible - - -class AssertFormErrorsMixin(object): - def assertFormErrors(self, expected, the_callable, *args, **kwargs): - try: - the_callable(*args, **kwargs) - self.fail("Testing the 'clean' method on %s failed to raise a ValidationError.") - except ValidationError as e: - self.assertEqual(e.messages, expected) - -class FormsErrorMessagesTestCase(TestCase, AssertFormErrorsMixin): - def test_charfield(self): - e = { - 'required': 'REQUIRED', - 'min_length': 'LENGTH %(show_value)s, MIN LENGTH %(limit_value)s', - 'max_length': 'LENGTH %(show_value)s, MAX LENGTH %(limit_value)s', - } - f = CharField(min_length=5, max_length=10, error_messages=e) - self.assertFormErrors(['REQUIRED'], f.clean, '') - self.assertFormErrors(['LENGTH 4, MIN LENGTH 5'], f.clean, '1234') - self.assertFormErrors(['LENGTH 11, MAX LENGTH 10'], f.clean, '12345678901') - - def test_integerfield(self): - e = { - 'required': 'REQUIRED', - 'invalid': 'INVALID', - 'min_value': 'MIN VALUE IS %(limit_value)s', - 'max_value': 'MAX VALUE IS %(limit_value)s', - } - f = IntegerField(min_value=5, max_value=10, error_messages=e) - self.assertFormErrors(['REQUIRED'], f.clean, '') - self.assertFormErrors(['INVALID'], f.clean, 'abc') - self.assertFormErrors(['MIN VALUE IS 5'], f.clean, '4') - self.assertFormErrors(['MAX VALUE IS 10'], f.clean, '11') - - def test_floatfield(self): - e = { - 'required': 'REQUIRED', - 'invalid': 'INVALID', - 'min_value': 'MIN VALUE IS %(limit_value)s', - 'max_value': 'MAX VALUE IS %(limit_value)s', - } - f = FloatField(min_value=5, max_value=10, error_messages=e) - self.assertFormErrors(['REQUIRED'], f.clean, '') - self.assertFormErrors(['INVALID'], f.clean, 'abc') - self.assertFormErrors(['MIN VALUE IS 5'], f.clean, '4') - self.assertFormErrors(['MAX VALUE IS 10'], f.clean, '11') - - def test_decimalfield(self): - e = { - 'required': 'REQUIRED', - 'invalid': 'INVALID', - 'min_value': 'MIN VALUE IS %(limit_value)s', - 'max_value': 'MAX VALUE IS %(limit_value)s', - 'max_digits': 'MAX DIGITS IS %s', - 'max_decimal_places': 'MAX DP IS %s', - 'max_whole_digits': 'MAX DIGITS BEFORE DP IS %s', - } - f = DecimalField(min_value=5, max_value=10, error_messages=e) - self.assertFormErrors(['REQUIRED'], f.clean, '') - self.assertFormErrors(['INVALID'], f.clean, 'abc') - self.assertFormErrors(['MIN VALUE IS 5'], f.clean, '4') - self.assertFormErrors(['MAX VALUE IS 10'], f.clean, '11') - - f2 = DecimalField(max_digits=4, decimal_places=2, error_messages=e) - self.assertFormErrors(['MAX DIGITS IS 4'], f2.clean, '123.45') - self.assertFormErrors(['MAX DP IS 2'], f2.clean, '1.234') - self.assertFormErrors(['MAX DIGITS BEFORE DP IS 2'], f2.clean, '123.4') - - def test_datefield(self): - e = { - 'required': 'REQUIRED', - 'invalid': 'INVALID', - } - f = DateField(error_messages=e) - self.assertFormErrors(['REQUIRED'], f.clean, '') - self.assertFormErrors(['INVALID'], f.clean, 'abc') - - def test_timefield(self): - e = { - 'required': 'REQUIRED', - 'invalid': 'INVALID', - } - f = TimeField(error_messages=e) - self.assertFormErrors(['REQUIRED'], f.clean, '') - self.assertFormErrors(['INVALID'], f.clean, 'abc') - - def test_datetimefield(self): - e = { - 'required': 'REQUIRED', - 'invalid': 'INVALID', - } - f = DateTimeField(error_messages=e) - self.assertFormErrors(['REQUIRED'], f.clean, '') - self.assertFormErrors(['INVALID'], f.clean, 'abc') - - def test_regexfield(self): - e = { - 'required': 'REQUIRED', - 'invalid': 'INVALID', - 'min_length': 'LENGTH %(show_value)s, MIN LENGTH %(limit_value)s', - 'max_length': 'LENGTH %(show_value)s, MAX LENGTH %(limit_value)s', - } - f = RegexField(r'^\d+$', min_length=5, max_length=10, error_messages=e) - self.assertFormErrors(['REQUIRED'], f.clean, '') - self.assertFormErrors(['INVALID'], f.clean, 'abcde') - self.assertFormErrors(['LENGTH 4, MIN LENGTH 5'], f.clean, '1234') - self.assertFormErrors(['LENGTH 11, MAX LENGTH 10'], f.clean, '12345678901') - - def test_emailfield(self): - e = { - 'required': 'REQUIRED', - 'invalid': 'INVALID', - 'min_length': 'LENGTH %(show_value)s, MIN LENGTH %(limit_value)s', - 'max_length': 'LENGTH %(show_value)s, MAX LENGTH %(limit_value)s', - } - f = EmailField(min_length=8, max_length=10, error_messages=e) - self.assertFormErrors(['REQUIRED'], f.clean, '') - self.assertFormErrors(['INVALID'], f.clean, 'abcdefgh') - self.assertFormErrors(['LENGTH 7, MIN LENGTH 8'], f.clean, 'a@b.com') - self.assertFormErrors(['LENGTH 11, MAX LENGTH 10'], f.clean, 'aye@bee.com') - - def test_filefield(self): - e = { - 'required': 'REQUIRED', - 'invalid': 'INVALID', - 'missing': 'MISSING', - 'empty': 'EMPTY FILE', - } - f = FileField(error_messages=e) - self.assertFormErrors(['REQUIRED'], f.clean, '') - self.assertFormErrors(['INVALID'], f.clean, 'abc') - self.assertFormErrors(['EMPTY FILE'], f.clean, SimpleUploadedFile('name', None)) - self.assertFormErrors(['EMPTY FILE'], f.clean, SimpleUploadedFile('name', '')) - - def test_urlfield(self): - e = { - 'required': 'REQUIRED', - 'invalid': 'INVALID', - } - f = URLField(error_messages=e) - self.assertFormErrors(['REQUIRED'], f.clean, '') - self.assertFormErrors(['INVALID'], f.clean, 'abc.c') - - def test_booleanfield(self): - e = { - 'required': 'REQUIRED', - } - f = BooleanField(error_messages=e) - self.assertFormErrors(['REQUIRED'], f.clean, '') - - def test_choicefield(self): - e = { - 'required': 'REQUIRED', - 'invalid_choice': '%(value)s IS INVALID CHOICE', - } - f = ChoiceField(choices=[('a', 'aye')], error_messages=e) - self.assertFormErrors(['REQUIRED'], f.clean, '') - self.assertFormErrors(['b IS INVALID CHOICE'], f.clean, 'b') - - def test_multiplechoicefield(self): - e = { - 'required': 'REQUIRED', - 'invalid_choice': '%(value)s IS INVALID CHOICE', - 'invalid_list': 'NOT A LIST', - } - f = MultipleChoiceField(choices=[('a', 'aye')], error_messages=e) - self.assertFormErrors(['REQUIRED'], f.clean, '') - self.assertFormErrors(['NOT A LIST'], f.clean, 'b') - self.assertFormErrors(['b IS INVALID CHOICE'], f.clean, ['b']) - - def test_splitdatetimefield(self): - e = { - 'required': 'REQUIRED', - 'invalid_date': 'INVALID DATE', - 'invalid_time': 'INVALID TIME', - } - f = SplitDateTimeField(error_messages=e) - self.assertFormErrors(['REQUIRED'], f.clean, '') - self.assertFormErrors(['INVALID DATE', 'INVALID TIME'], f.clean, ['a', 'b']) - - def test_ipaddressfield(self): - e = { - 'required': 'REQUIRED', - 'invalid': 'INVALID IP ADDRESS', - } - f = IPAddressField(error_messages=e) - self.assertFormErrors(['REQUIRED'], f.clean, '') - self.assertFormErrors(['INVALID IP ADDRESS'], f.clean, '127.0.0') - - def test_generic_ipaddressfield(self): - e = { - 'required': 'REQUIRED', - 'invalid': 'INVALID IP ADDRESS', - } - f = GenericIPAddressField(error_messages=e) - self.assertFormErrors(['REQUIRED'], f.clean, '') - self.assertFormErrors(['INVALID IP ADDRESS'], f.clean, '127.0.0') - - def test_subclassing_errorlist(self): - class TestForm(Form): - first_name = CharField() - last_name = CharField() - birthday = DateField() - - def clean(self): - raise ValidationError("I like to be awkward.") - - @python_2_unicode_compatible - class CustomErrorList(util.ErrorList): - def __str__(self): - return self.as_divs() - - def as_divs(self): - if not self: return '' - return mark_safe('
%s
' % ''.join(['

%s

' % e for e in self])) - - # This form should print errors the default way. - form1 = TestForm({'first_name': 'John'}) - self.assertHTMLEqual(str(form1['last_name'].errors), '
  • This field is required.
') - self.assertHTMLEqual(str(form1.errors['__all__']), '
  • I like to be awkward.
') - - # This one should wrap error groups in the customized way. - form2 = TestForm({'first_name': 'John'}, error_class=CustomErrorList) - self.assertHTMLEqual(str(form2['last_name'].errors), '

This field is required.

') - self.assertHTMLEqual(str(form2.errors['__all__']), '

I like to be awkward.

') - - -class ModelChoiceFieldErrorMessagesTestCase(TestCase, AssertFormErrorsMixin): - def test_modelchoicefield(self): - # Create choices for the model choice field tests below. - from regressiontests.forms.models import ChoiceModel - c1 = ChoiceModel.objects.create(pk=1, name='a') - c2 = ChoiceModel.objects.create(pk=2, name='b') - c3 = ChoiceModel.objects.create(pk=3, name='c') - - # ModelChoiceField - e = { - 'required': 'REQUIRED', - 'invalid_choice': 'INVALID CHOICE', - } - f = ModelChoiceField(queryset=ChoiceModel.objects.all(), error_messages=e) - self.assertFormErrors(['REQUIRED'], f.clean, '') - self.assertFormErrors(['INVALID CHOICE'], f.clean, '4') - - # ModelMultipleChoiceField - e = { - 'required': 'REQUIRED', - 'invalid_choice': '%s IS INVALID CHOICE', - 'list': 'NOT A LIST OF VALUES', - } - f = ModelMultipleChoiceField(queryset=ChoiceModel.objects.all(), error_messages=e) - self.assertFormErrors(['REQUIRED'], f.clean, '') - self.assertFormErrors(['NOT A LIST OF VALUES'], f.clean, '3') - self.assertFormErrors(['4 IS INVALID CHOICE'], f.clean, ['4']) diff --git a/tests/forms/tests/extra.py b/tests/forms/tests/extra.py deleted file mode 100644 index 359ad442bc..0000000000 --- a/tests/forms/tests/extra.py +++ /dev/null @@ -1,807 +0,0 @@ -# -*- coding: utf-8 -*- -from __future__ import absolute_import, unicode_literals - -import datetime - -from django.forms import * -from django.forms.extras import SelectDateWidget -from django.forms.util import ErrorList -from django.test import TestCase -from django.test.utils import override_settings -from django.utils import six -from django.utils import translation -from django.utils.encoding import force_text, smart_text, python_2_unicode_compatible - -from .error_messages import AssertFormErrorsMixin - - -class GetDate(Form): - mydate = DateField(widget=SelectDateWidget) - -class GetNotRequiredDate(Form): - mydate = DateField(widget=SelectDateWidget, required=False) - -class GetDateShowHiddenInitial(Form): - mydate = DateField(widget=SelectDateWidget, show_hidden_initial=True) - -class FormsExtraTestCase(TestCase, AssertFormErrorsMixin): - ############### - # Extra stuff # - ############### - - # The forms library comes with some extra, higher-level Field and Widget - def test_selectdate(self): - w = SelectDateWidget(years=('2007','2008','2009','2010','2011','2012','2013','2014','2015','2016')) - self.assertHTMLEqual(w.render('mydate', ''), """ - - - -""") - self.assertHTMLEqual(w.render('mydate', None), w.render('mydate', '')) - - self.assertHTMLEqual(w.render('mydate', '2010-04-15'), """ - -""") - - # Accepts a datetime or a string: - self.assertHTMLEqual(w.render('mydate', datetime.date(2010, 4, 15)), w.render('mydate', '2010-04-15')) - - # Invalid dates still render the failed date: - self.assertHTMLEqual(w.render('mydate', '2010-02-31'), """ - -""") - - # Using a SelectDateWidget in a form: - w = SelectDateWidget(years=('2007','2008','2009','2010','2011','2012','2013','2014','2015','2016'), required=False) - self.assertHTMLEqual(w.render('mydate', ''), """ - -""") - self.assertHTMLEqual(w.render('mydate', '2010-04-15'), """ - -""") - - a = GetDate({'mydate_month':'4', 'mydate_day':'1', 'mydate_year':'2008'}) - self.assertTrue(a.is_valid()) - self.assertEqual(a.cleaned_data['mydate'], datetime.date(2008, 4, 1)) - - # As with any widget that implements get_value_from_datadict, - # we must be prepared to accept the input from the "as_hidden" - # rendering as well. - - self.assertHTMLEqual(a['mydate'].as_hidden(), '') - - b = GetDate({'mydate':'2008-4-1'}) - self.assertTrue(b.is_valid()) - self.assertEqual(b.cleaned_data['mydate'], datetime.date(2008, 4, 1)) - - # Invalid dates shouldn't be allowed - c = GetDate({'mydate_month':'2', 'mydate_day':'31', 'mydate_year':'2010'}) - self.assertFalse(c.is_valid()) - self.assertEqual(c.errors, {'mydate': ['Enter a valid date.']}) - - # label tag is correctly associated with month dropdown - d = GetDate({'mydate_month':'1', 'mydate_day':'1', 'mydate_year':'2010'}) - self.assertTrue('