desc
stringlengths
3
26.7k
decl
stringlengths
11
7.89k
bodies
stringlengths
8
553k
'default: manage.py builtin commands fail if settings file (from environment) doesn\'t exist'
def test_builtin_with_bad_environment(self):
args = ['sqlall', 'admin_scripts'] (out, err) = self.run_manage(args, 'bad_settings') self.assertNoOutput(out) self.assertOutput(err, "Could not import settings 'bad_settings'")
'default: manage.py can execute user commands when default settings are appropriate'
def test_custom_command(self):
args = ['noargs_command'] (out, err) = self.run_manage(args) self.assertNoOutput(err) self.assertOutput(out, 'EXECUTE:NoArgsCommand')
'default: manage.py can execute user commands when settings are provided as argument'
def test_custom_command_with_settings(self):
args = ['noargs_command', '--settings=regressiontests.settings'] (out, err) = self.run_manage(args) self.assertNoOutput(err) self.assertOutput(out, 'EXECUTE:NoArgsCommand')
'default: manage.py can execute user commands when settings are provided in environment'
def test_custom_command_with_environment(self):
args = ['noargs_command'] (out, err) = self.run_manage(args, 'regressiontests.settings') self.assertNoOutput(err) self.assertOutput(out, 'EXECUTE:NoArgsCommand')
'fulldefault: manage.py builtin commands succeed when default settings are appropriate'
def test_builtin_command(self):
args = ['sqlall', 'admin_scripts'] (out, err) = self.run_manage(args) self.assertNoOutput(err) self.assertOutput(out, 'CREATE TABLE')
'fulldefault: manage.py builtin commands succeed if settings are provided as argument'
def test_builtin_with_settings(self):
args = ['sqlall', '--settings=regressiontests.settings', 'admin_scripts'] (out, err) = self.run_manage(args) self.assertNoOutput(err) self.assertOutput(out, 'CREATE TABLE')
'fulldefault: manage.py builtin commands succeed if settings are provided in the environment'
def test_builtin_with_environment(self):
args = ['sqlall', 'admin_scripts'] (out, err) = self.run_manage(args, 'regressiontests.settings') self.assertNoOutput(err) self.assertOutput(out, 'CREATE TABLE')
'fulldefault: manage.py builtin commands succeed if settings file (from argument) doesn\'t exist'
def test_builtin_with_bad_settings(self):
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'")
'fulldefault: manage.py builtin commands fail if settings file (from environment) doesn\'t exist'
def test_builtin_with_bad_environment(self):
args = ['sqlall', 'admin_scripts'] (out, err) = self.run_manage(args, 'bad_settings') self.assertNoOutput(out) self.assertOutput(err, "Could not import settings 'bad_settings'")
'fulldefault: manage.py can execute user commands when default settings are appropriate'
def test_custom_command(self):
args = ['noargs_command'] (out, err) = self.run_manage(args) self.assertNoOutput(err) self.assertOutput(out, 'EXECUTE:NoArgsCommand')
'fulldefault: manage.py can execute user commands when settings are provided as argument'
def test_custom_command_with_settings(self):
args = ['noargs_command', '--settings=regressiontests.settings'] (out, err) = self.run_manage(args) self.assertNoOutput(err) self.assertOutput(out, 'EXECUTE:NoArgsCommand')
'fulldefault: manage.py can execute user commands when settings are provided in environment'
def test_custom_command_with_environment(self):
args = ['noargs_command'] (out, err) = self.run_manage(args, 'regressiontests.settings') self.assertNoOutput(err) self.assertOutput(out, 'EXECUTE:NoArgsCommand')
'minimal: manage.py builtin commands fail with an import error when no settings provided'
def test_builtin_command(self):
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')
'minimal: manage.py builtin commands fail if settings are provided as argument'
def test_builtin_with_settings(self):
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')
'minimal: manage.py builtin commands fail if settings are provided in the environment'
def test_builtin_with_environment(self):
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')
'minimal: manage.py builtin commands fail if settings file (from argument) doesn\'t exist'
def test_builtin_with_bad_settings(self):
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'")
'minimal: manage.py builtin commands fail if settings file (from environment) doesn\'t exist'
def test_builtin_with_bad_environment(self):
args = ['sqlall', 'admin_scripts'] (out, err) = self.run_manage(args, 'bad_settings') self.assertNoOutput(out) self.assertOutput(err, "Could not import settings 'bad_settings'")
'minimal: manage.py can\'t execute user commands without appropriate settings'
def test_custom_command(self):
args = ['noargs_command'] (out, err) = self.run_manage(args) self.assertNoOutput(out) self.assertOutput(err, "Unknown command: 'noargs_command'")
'minimal: manage.py can\'t execute user commands, even if settings are provided as argument'
def test_custom_command_with_settings(self):
args = ['noargs_command', '--settings=regressiontests.settings'] (out, err) = self.run_manage(args) self.assertNoOutput(out) self.assertOutput(err, "Unknown command: 'noargs_command'")
'minimal: manage.py can\'t execute user commands, even if settings are provided in environment'
def test_custom_command_with_environment(self):
args = ['noargs_command'] (out, err) = self.run_manage(args, 'regressiontests.settings') self.assertNoOutput(out) self.assertOutput(err, "Unknown command: 'noargs_command'")
'alternate: manage.py builtin commands fail with an import error when no default settings provided'
def test_builtin_command(self):
args = ['sqlall', 'admin_scripts'] (out, err) = self.run_manage(args) self.assertNoOutput(out) self.assertOutput(err, "Could not import settings 'regressiontests.settings'")
'alternate: manage.py builtin commands work with settings provided as argument'
def test_builtin_with_settings(self):
args = ['sqlall', '--settings=alternate_settings', 'admin_scripts'] (out, err) = self.run_manage(args) self.assertRegexpMatches(out, expected_query_re) self.assertNoOutput(err)
'alternate: manage.py builtin commands work if settings are provided in the environment'
def test_builtin_with_environment(self):
args = ['sqlall', 'admin_scripts'] (out, err) = self.run_manage(args, 'alternate_settings') self.assertRegexpMatches(out, expected_query_re) self.assertNoOutput(err)
'alternate: manage.py builtin commands fail if settings file (from argument) doesn\'t exist'
def test_builtin_with_bad_settings(self):
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'")
'alternate: manage.py builtin commands fail if settings file (from environment) doesn\'t exist'
def test_builtin_with_bad_environment(self):
args = ['sqlall', 'admin_scripts'] (out, err) = self.run_manage(args, 'bad_settings') self.assertNoOutput(out) self.assertOutput(err, "Could not import settings 'bad_settings'")
'alternate: manage.py can\'t execute user commands without settings'
def test_custom_command(self):
args = ['noargs_command'] (out, err) = self.run_manage(args) self.assertNoOutput(out) self.assertOutput(err, "Unknown command: 'noargs_command'")
'alternate: manage.py can execute user commands if settings are provided as argument'
def test_custom_command_with_settings(self):
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)
'alternate: manage.py can execute user commands if settings are provided in environment'
def test_custom_command_with_environment(self):
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)
'multiple: manage.py builtin commands fail with an import error when no settings provided'
def test_builtin_command(self):
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.')
'multiple: manage.py builtin commands succeed if settings are provided as argument'
def test_builtin_with_settings(self):
args = ['sqlall', '--settings=alternate_settings', 'admin_scripts'] (out, err) = self.run_manage(args) self.assertNoOutput(err) self.assertOutput(out, 'CREATE TABLE')
'multiple: manage.py can execute builtin commands if settings are provided in the environment'
def test_builtin_with_environment(self):
args = ['sqlall', 'admin_scripts'] (out, err) = self.run_manage(args, 'alternate_settings') self.assertNoOutput(err) self.assertOutput(out, 'CREATE TABLE')
'multiple: manage.py builtin commands fail if settings file (from argument) doesn\'t exist'
def test_builtin_with_bad_settings(self):
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'")
'multiple: manage.py builtin commands fail if settings file (from environment) doesn\'t exist'
def test_builtin_with_bad_environment(self):
args = ['sqlall', 'admin_scripts'] (out, err) = self.run_manage(args, 'bad_settings') self.assertNoOutput(out) self.assertOutput(err, "Could not import settings 'bad_settings'")
'multiple: manage.py can\'t execute user commands using default settings'
def test_custom_command(self):
args = ['noargs_command'] (out, err) = self.run_manage(args) self.assertNoOutput(out) self.assertOutput(err, "Unknown command: 'noargs_command'")
'multiple: manage.py can execute user commands if settings are provided as argument'
def test_custom_command_with_settings(self):
args = ['noargs_command', '--settings=alternate_settings'] (out, err) = self.run_manage(args) self.assertNoOutput(err) self.assertOutput(out, 'EXECUTE:NoArgsCommand')
'multiple: manage.py can execute user commands if settings are provided in environment'
def test_custom_command_with_environment(self):
args = ['noargs_command'] (out, err) = self.run_manage(args, 'alternate_settings') self.assertNoOutput(err) self.assertOutput(out, 'EXECUTE:NoArgsCommand')
'import error: manage.py builtin commands shows useful diagnostic info when settings with import errors is provided'
def test_builtin_command(self):
args = ['sqlall', 'admin_scripts'] (out, err) = self.run_manage(args) self.assertNoOutput(out) self.assertOutput(err, 'No module named foo42bar')
'manage.py validate reports an error on a non-existent app in INSTALLED_APPS'
def test_nonexistent_app(self):
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 admin_scriptz')
'manage.py validate reports an ImportError if an app\'s models.py raises one on import'
def test_broken_app(self):
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')
'manage.py validate does not raise an ImportError validating a complex app with nested calls to load_app'
def test_complex_app(self):
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')
'manage.py validate does not raise errors when an app imports a base class that itself has an abstract base'
def test_app_with_import(self):
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...
'Ensure that the --liveserver option sets the environment variable correctly. Refs #2879.'
def test_liveserver(self):
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.assertEqual(('DJANGO_LIVE_TEST_SERVER_ADDRESS' in os.environ), addre...
'version is handled as a special case'
def test_version(self):
args = ['version'] (out, err) = self.run_manage(args) self.assertNoOutput(err) self.assertOutput(out, get_version())
'--version is equivalent to version'
def test_version_alternative(self):
(args1, args2) = (['version'], ['--version']) self.assertEqual(self.run_manage(args1), self.run_manage(args2))
'help is handled as a special case'
def test_help(self):
args = ['help'] (out, err) = self.run_manage(args) self.assertOutput(out, 'Usage: manage.py subcommand [options] [args]') self.assertOutput(out, "Type 'manage.py help <subcommand>' for help on a specific subcommand.") self.assertOutput(out, '[django]') self...
'help --commands shows the list of all available commands'
def test_help_commands(self):
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...
'--help is equivalent to help'
def test_help_alternative(self):
(args1, args2) = (['help'], ['--help']) self.assertEqual(self.run_manage(args1), self.run_manage(args2))
'-h is handled as a short form of --help'
def test_help_short_altert(self):
(args1, args2) = (['--help'], ['-h']) self.assertEqual(self.run_manage(args1), self.run_manage(args2))
'--help can be used on a specific command'
def test_specific_help(self):
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).')
'User BaseCommands can execute when a label is provided'
def test_base_command(self):
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),...
'User BaseCommands can execute when no labels are provided'
def test_base_command_no_label(self):
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...
'User BaseCommands can execute when no labels are provided'
def test_base_command_multiple_label(self):
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', ...
'User BaseCommands can execute with options when a label is provided'
def test_base_command_with_option(self):
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), ('sett...
'User BaseCommands can execute with multiple options when a label is provided'
def test_base_command_with_options(self):
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)...
'NoArg Commands can be executed'
def test_noargs(self):
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')]")
'NoArg Commands raise an error if an argument is provided'
def test_noargs_with_args(self):
args = ['noargs_command', 'argument'] (out, err) = self.run_manage(args) self.assertOutput(err, "Error: Command doesn't accept any arguments")
'User AppCommands can execute when a single app name is provided'
def test_app_command(self):
args = ['app_command', 'auth'] (out, err) = self.run_manage(args) self.assertNoOutput(err) self.assertOutput(out, "EXECUTE:AppCommand app=<module 'django.contrib.auth.models'") self.assertOutput(out, os.sep.join(['django', 'contrib', 'auth', 'models.py'])) self.assertOutput(out, "'>, op...
'User AppCommands raise an error when no app name is provided'
def test_app_command_no_apps(self):
args = ['app_command'] (out, err) = self.run_manage(args) self.assertOutput(err, 'Error: Enter at least one appname.')
'User AppCommands raise an error when multiple app names are provided'
def test_app_command_multiple_apps(self):
args = ['app_command', 'auth', 'contenttypes'] (out, err) = self.run_manage(args) self.assertNoOutput(err) self.assertOutput(out, "EXECUTE:AppCommand app=<module 'django.contrib.auth.models'") self.assertOutput(out, os.sep.join(['django', 'contrib', 'auth', 'models.py'])) self.assertOutput...
'User AppCommands can execute when a single app name is provided'
def test_app_command_invalid_appname(self):
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')
'User AppCommands can execute when some of the provided app names are invalid'
def test_app_command_some_invalid_appnames(self):
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')
'User LabelCommands can execute when a label is provided'
def test_label_command(self):
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')]")
'User LabelCommands raise an error if no label is provided'
def test_label_command_no_label(self):
args = ['label_command'] (out, err) = self.run_manage(args) self.assertOutput(err, 'Enter at least one label')
'User LabelCommands are executed multiple times if multiple labels are provided'
def test_label_command_multiple_label(self):
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')]") sel...
'Options passed after settings are correctly handled'
def test_setting_then_option(self):
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'), (...
'Short options passed after settings are correctly handled'
def test_setting_then_short_option(self):
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'), (...
'Options passed before settings are correctly handled'
def test_option_then_setting(self):
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'), (...
'Short options passed before settings are correctly handled'
def test_short_option_then_setting(self):
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'), ('pyth...
'Options are correctly handled when they are passed before and after a setting'
def test_option_then_setting_then_option(self):
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...
'Make sure passing the wrong kinds of arguments raises a CommandError'
def test_wrong_args(self):
(out, err) = self.run_django_admin(['startproject']) self.assertNoOutput(out) self.assertOutput(err, 'you must provide a project name')
'Make sure the startproject management command creates a project'
def test_simple_project(self):
args = ['startproject', 'testproject'] testproject_dir = os.path.join(test_dir, 'testproject') (out, err) = self.run_django_admin(args) self.addCleanup(shutil.rmtree, testproject_dir) self.assertNoOutput(err) self.assertTrue(os.path.isdir(testproject_dir)) (out, err) = self.run_django_admin(...
'Make sure the startproject management command validates a project name'
def test_invalid_project_name(self):
def cleanup(p): if os.path.exists(p): shutil.rmtree(p) args = ['startproject', '7testproject'] testproject_dir = os.path.join(test_dir, '7testproject') (out, err) = self.run_django_admin(args) self.addCleanup(cleanup, testproject_dir) self.assertOutput(err, "Error: '7testp...
'Make sure the startproject management command creates a project in a specific directory'
def test_simple_project_different_directory(self):
args = ['startproject', 'testproject', 'othertestproject'] testproject_dir = os.path.join(test_dir, 'othertestproject') os.mkdir(testproject_dir) (out, err) = self.run_django_admin(args) self.addCleanup(shutil.rmtree, testproject_dir) self.assertNoOutput(err) self.assertTrue(os.path.exists(o...
'Make sure the startproject management command is able to use a different project template'
def test_custom_project_template(self):
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') (out, err) = self.run_django_admin(args) self.addCleanup(shutil.rmtr...
'Ticket 17475: Template dir passed has a trailing path separator'
def test_template_dir_with_trailing_slash(self):
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') (out, err) = self.run_django_admin(args) self.addCleanup(...
'Make sure the startproject management command is able to use a different project template from a tarball'
def test_custom_project_template_from_tarball_by_path(self):
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') (out, err) = self.run_django_admin(args) self.addCleanup(shuti...
'Startproject can use a project template from a tarball and create it in a specified location'
def test_custom_project_template_from_tarball_to_alternative_location(self):
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) (out, err) = self.run_django...
'Make sure the startproject management command is able to use a different project template from a tarball via a url'
def test_custom_project_template_from_tarball_by_url(self):
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') (out, err) = self.run_django_admin(args) self.addCleanup(shutil.rmtree, te...
'Startproject management command handles project template tar/zip balls from non-canonical urls'
def test_project_template_tarball_url(self):
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') (out, err) = self.run_django_admin(args) self.addCleanup(shutil.rmtree, t...
'Make sure the startproject management command is able to render custom files'
def test_file_without_extension(self):
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') (out, err) = self.run_django_admin(args) ...
'Make sure template context variables are rendered with proper values'
def test_custom_project_template_context_variables(self):
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) (out, err) = self.run_django_admin(...
'Make sure an exception is raised when the provided destination directory doesn\'t exist'
def test_custom_project_destination_missing(self):
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.assertNoO...
'Executing the changepassword management command with a database option should operate on the specified DB'
def test_that_changepassword_command_with_database_option_uses_given_db(self):
self.assertTrue(self.user.check_password('qwerty')) command = changepassword.Command() command._get_pass = (lambda *args: 'not qwerty') command.execute('joe', database='other', stdout=self.stdout) command_output = self.stdout.getvalue().strip() self.assertEquals(command_output, "Changing p...
'createsuperuser command should operate on specified DB'
def test_createsuperuser_command_with_database_option(self):
new_io = StringIO() call_command('createsuperuser', interactive=False, username='joe', email='joe@somewhere.org', database='other', stdout=new_io) command_output = new_io.getvalue().strip() self.assertEqual(command_output, 'Superuser created successfully.') u = models.User.objects.using('other...
'Can find a file in a STATICFILES_DIRS directory.'
def test_staticfiles_dirs(self):
self.assertFileContains('test.txt', 'Can we find') self.assertFileContains(os.path.join('prefix', 'test.txt'), 'Prefix')
'Can find a file in a subdirectory of a STATICFILES_DIRS directory.'
def test_staticfiles_dirs_subdir(self):
self.assertFileContains('subdir/test.txt', 'Can we find')
'File in STATICFILES_DIRS has priority over file in app.'
def test_staticfiles_dirs_priority(self):
self.assertFileContains('test/file.txt', 'STATICFILES_DIRS')
'Can find a file in an app static/ directory.'
def test_app_files(self):
self.assertFileContains('test/file1.txt', 'file1 in the app dir')
'Can find a file with non-ASCII character in an app static/ directory.'
def test_nonascii_filenames(self):
self.assertFileContains(u'test/fi\u015fier.txt', u'fi\u015fier in the app dir')
'Can find a file with capital letters.'
def test_camelcase_filenames(self):
self.assertFileContains(u'test/camelCase.txt', u'camelCase')
'Test that findstatic returns all candidate files if run without --first.'
def test_all_files(self):
_stdout = sys.stdout sys.stdout = StringIO() try: call_command('findstatic', 'test/file.txt', verbosity='0') sys.stdout.seek(0) lines = [l.strip() for l in sys.stdout.readlines()] finally: sys.stdout = _stdout self.assertEqual(len(lines), 3) self.assertIn('project...
'Test that -i patterns are ignored.'
def test_ignore(self):
self.assertFileNotFound('test/test.ignoreme')
'Common ignore patterns (*~, .*, CVS) are ignored.'
def test_common_ignore_patterns(self):
self.assertFileNotFound('test/.hidden') self.assertFileNotFound('test/backup~') self.assertFileNotFound('test/CVS')
'With --no-default-ignore, common ignore patterns (*~, .*, CVS) are not ignored.'
def test_no_common_ignore_patterns(self):
self.assertFileContains('test/.hidden', 'should be ignored') self.assertFileContains('test/backup~', 'should be ignored') self.assertFileContains('test/CVS', 'should be ignored')
'Make sure no files were create in the destination directory.'
def test_no_files_created(self):
self.assertEqual(os.listdir(settings.STATIC_ROOT), [])
'Test if collectstatic takes files in proper order'
def test_ordering_override(self):
self.assertFileContains('file2.txt', 'duplicate of file2.txt') self.run_collectstatic() self.assertFileContains('file2.txt', 'duplicate of file2.txt') mtime = os.path.getmtime(self.testfile_path) atime = os.path.getatime(self.testfile_path) os.utime(self.orig_path, ((mtime + 1), (ati...
'Test the CachedStaticFilesStorage backend.'
def test_template_tag_return(self):
self.assertStaticRaises(ValueError, 'does/not/exist.png', '/static/does/not/exist.png') self.assertStaticRenders('test/file.txt', '/static/test/file.dad0999e4f8f.txt') self.assertStaticRenders('cached/styles.css', '/static/cached/styles.93b1147e8552.css') self.assertStaticRenders('path/', '/static/path/...
'Test that post_processing behaves correctly. Files that are alterable should always be post-processed; files that aren\'t should be skipped. collectstatic has already been called once in setUp() for this testcase, therefore we check by verifying behavior on a second run.'
def test_post_processing(self):
collectstatic_args = {'interactive': False, 'verbosity': '0', 'link': False, 'clear': False, 'dry_run': False, 'post_process': True, 'use_default_ignore_patterns': True, 'ignore_patterns': ['*.ignoreme']} collectstatic_cmd = CollectstaticCommand() collectstatic_cmd.set_options(**collectstatic_args) stat...
'Handle cache key creation correctly, see #17861.'
def test_cache_key_memcache_validation(self):
name = (('/some crazy/long filename/ with spaces Here and ?#%#$/other/stuff/some crazy/long filename/ with spaces Here and ?#%#$/other/stuff/some crazy/long filename/ with spaces Here and ?#%#$/other/stuff/some crazy/long filename/ with spac...
'We can\'t determine if STATICFILES_DIRS is set correctly just by looking at the type, but we can determine if it\'s definitely wrong.'
@override_settings(STATICFILES_DIRS='a string') def test_non_tuple_raises_exception(self):
self.assertRaises(ImproperlyConfigured, finders.FileSystemFinder)