Ticket #13612: 13612.diff
File 13612.diff, 4.7 KB (added by , 14 years ago) |
---|
-
tests/regressiontests/admin_scripts/tests.py
840 840 self.assertOutput(err, "Can't find the file 'settings.py' in the directory containing './manage.py'") 841 841 842 842 def test_builtin_with_settings(self): 843 "alternate: manage.py builtin commands fail if settings are provided as argument but no defaults"843 "alternate: manage.py builtin commands succeed if settings are provided as argument" 844 844 args = ['sqlall','--settings=alternate_settings', 'admin_scripts'] 845 845 out, err = self.run_manage(args) 846 self.assertNoOutput( out)847 self.assertOutput( err, "Can't find the file 'settings.py' in the directory containing './manage.py'")846 self.assertNoOutput(err) 847 self.assertOutput(out, 'CREATE TABLE') 848 848 849 849 def test_builtin_with_environment(self): 850 "alternate: manage.py builtin commands fail if settings are provided in the environment but no defaults"850 "alternate: manage.py builtin commands succeed if settings are provided in the environment" 851 851 args = ['sqlall','admin_scripts'] 852 852 out, err = self.run_manage(args,'alternate_settings') 853 self.assertNoOutput( out)854 self.assertOutput( err, "Can't find the file 'settings.py' in the directory containing './manage.py'")853 self.assertNoOutput(err) 854 self.assertOutput(out, 'CREATE TABLE') 855 855 856 856 def test_builtin_with_bad_settings(self): 857 857 "alternate: manage.py builtin commands fail if settings file (from argument) doesn't exist" … … 868 868 self.assertOutput(err, "Can't find the file 'settings.py' in the directory containing './manage.py'") 869 869 870 870 def test_custom_command(self): 871 "alternate: manage.py can't execute user commands "871 "alternate: manage.py can't execute user commands if it isn't provided settings" 872 872 args = ['noargs_command'] 873 873 out, err = self.run_manage(args) 874 874 self.assertNoOutput(out) 875 self.assertOutput(err, " Can't find the file 'settings.py' in the directory containing './manage.py'")875 self.assertOutput(err, "Unknown command: 'noargs_command'") 876 876 877 877 def test_custom_command_with_settings(self): 878 "alternate: manage.py can 't execute user commands, evenif settings are provided as argument"878 "alternate: manage.py can execute user commands if settings are provided as argument" 879 879 args = ['noargs_command', '--settings=alternate_settings'] 880 880 out, err = self.run_manage(args) 881 self.assertNoOutput( out)882 self.assertOutput( err, "Can't find the file 'settings.py' in the directory containing './manage.py'")881 self.assertNoOutput(err) 882 self.assertOutput(out, "EXECUTE:NoArgsCommand") 883 883 884 884 def test_custom_command_with_environment(self): 885 "alternate: manage.py can 't execute user commands, evenif settings are provided in environment"885 "alternate: manage.py can execute user commands if settings are provided in environment" 886 886 args = ['noargs_command'] 887 887 out, err = self.run_manage(args,'alternate_settings') 888 self.assertNoOutput( out)889 self.assertOutput( err, "Can't find the file 'settings.py' in the directory containing './manage.py'")888 self.assertNoOutput(err) 889 self.assertOutput(out, "EXECUTE:NoArgsCommand") 890 890 891 891 892 892 class ManageMultipleSettings(AdminScriptTestCase): -
django/conf/project_template/manage.py
1 1 #!/usr/bin/env python 2 from django.core .management import execute_manager2 from django.core import management 3 3 import imp 4 4 5 try: 5 6 imp.find_module('settings') # Assumed to be in the same directory. 7 6 8 except ImportError: 9 7 10 import sys 8 sys.stderr.write("Error: Can't find the file 'settings.py' in the directory containing %r. It appears you've customized things.\nYou'll have to run django-admin.py, passing it your settings module.\n" % __file__) 11 12 try: 13 # No settings.py, try like django-admin.py does 14 management.execute_from_command_line() 15 except ImportError: 16 sys.stderr.write("Error: Can't find the file 'settings.py' in the directory containing %r. It appears you've customized things.\nYou'll have to run django-admin.py, passing it your settings module.\n" % __file__) 17 9 18 sys.exit(1) 10 19 11 20 import settings 12 21 13 22 if __name__ == "__main__": 14 execute_manager(settings)23 management.execute_manager(settings)