Code

Ticket #10706: t10706.diff

File t10706.diff, 6.0 KB (added by seveas, 5 years ago)

Make the error message clearer

Line 
1Index: tests/regressiontests/admin_scripts/tests.py
2===================================================================
3--- tests/regressiontests/admin_scripts/tests.py        (revision 11211)
4+++ tests/regressiontests/admin_scripts/tests.py        (working copy)
5@@ -337,14 +337,14 @@
6         args = ['sqlall','--settings=settings', 'admin_scripts']
7         out, err = self.run_django_admin(args)
8         self.assertNoOutput(out)
9-        self.assertOutput(err, 'App with label admin_scripts could not be found')
10+        self.assertOutput(err, 'App with label admin_scripts could not be found or caused an error during import')
11 
12     def test_builtin_with_environment(self):
13         "minimal: django-admin builtin commands fail if settings are provided in the environment"
14         args = ['sqlall','admin_scripts']
15         out, err = self.run_django_admin(args,'settings')
16         self.assertNoOutput(out)
17-        self.assertOutput(err, 'App with label admin_scripts could not be found')
18+        self.assertOutput(err, 'App with label admin_scripts could not be found or caused an error during import')
19 
20     def test_builtin_with_bad_settings(self):
21         "minimal: django-admin builtin commands fail if settings file (from argument) doesn't exist"
22@@ -760,21 +760,21 @@
23         args = ['sqlall','admin_scripts']
24         out, err = self.run_manage(args)
25         self.assertNoOutput(out)
26-        self.assertOutput(err, 'App with label admin_scripts could not be found')
27+        self.assertOutput(err, 'App with label admin_scripts could not be found or caused an error during import')
28 
29     def test_builtin_with_settings(self):
30         "minimal: manage.py builtin commands fail if settings are provided as argument"
31         args = ['sqlall','--settings=settings', 'admin_scripts']
32         out, err = self.run_manage(args)
33         self.assertNoOutput(out)
34-        self.assertOutput(err, 'App with label admin_scripts could not be found')
35+        self.assertOutput(err, 'App with label admin_scripts could not be found or caused an error during import')
36 
37     def test_builtin_with_environment(self):
38         "minimal: manage.py builtin commands fail if settings are provided in the environment"
39         args = ['sqlall','admin_scripts']
40         out, err = self.run_manage(args,'settings')
41         self.assertNoOutput(out)
42-        self.assertOutput(err, 'App with label admin_scripts could not be found')
43+        self.assertOutput(err, 'App with label admin_scripts could not be found or caused an error during import')
44 
45     def test_builtin_with_bad_settings(self):
46         "minimal: manage.py builtin commands fail if settings file (from argument) doesn't exist"
47@@ -788,7 +788,7 @@
48         args = ['sqlall','admin_scripts']
49         out, err = self.run_manage(args,'bad_settings')
50         self.assertNoOutput(out)
51-        self.assertOutput(err, 'App with label admin_scripts could not be found')
52+        self.assertOutput(err, 'App with label admin_scripts could not be found or caused an error during import')
53 
54     def test_custom_command(self):
55         "minimal: manage.py can't execute user commands without appropriate settings"
56@@ -897,7 +897,7 @@
57         args = ['sqlall','admin_scripts']
58         out, err = self.run_manage(args)
59         self.assertNoOutput(out)
60-        self.assertOutput(err, 'App with label admin_scripts could not be found.')
61+        self.assertOutput(err, 'App with label admin_scripts could not be found or caused an error during import.')
62 
63     def test_builtin_with_settings(self):
64         "multiple: manage.py builtin commands succeed if settings are provided as argument"
65@@ -912,7 +912,7 @@
66         args = ['sqlall','admin_scripts']
67         out, err = self.run_manage(args,'alternate_settings')
68         self.assertNoOutput(out)
69-        self.assertOutput(err, 'App with label admin_scripts could not be found.')
70+        self.assertOutput(err, 'App with label admin_scripts could not be found or caused an error during import.')
71 
72     def test_builtin_with_bad_settings(self):
73         "multiple: manage.py builtin commands fail if settings file (from argument) doesn't exist"
74@@ -926,7 +926,7 @@
75         args = ['sqlall','admin_scripts']
76         out, err = self.run_manage(args,'bad_settings')
77         self.assertNoOutput(out)
78-        self.assertOutput(err, "App with label admin_scripts could not be found")
79+        self.assertOutput(err, "App with label admin_scripts could not be found or caused an error during import")
80 
81     def test_custom_command(self):
82         "multiple: manage.py can't execute user commands using default settings"
83@@ -1067,13 +1067,13 @@
84         "User AppCommands can execute when a single app name is provided"
85         args = ['app_command', 'NOT_AN_APP']
86         out, err = self.run_manage(args)
87-        self.assertOutput(err, "App with label NOT_AN_APP could not be found")
88+        self.assertOutput(err, "App with label NOT_AN_APP could not be found or caused an error during import")
89 
90     def test_app_command_some_invalid_appnames(self):
91         "User AppCommands can execute when some of the provided app names are invalid"
92         args = ['app_command', 'auth', 'NOT_AN_APP']
93         out, err = self.run_manage(args)
94-        self.assertOutput(err, "App with label NOT_AN_APP could not be found")
95+        self.assertOutput(err, "App with label NOT_AN_APP could not be found or caused an error during import")
96 
97     def test_label_command(self):
98         "User LabelCommands can execute when a label is provided"
99Index: django/db/models/loading.py
100===================================================================
101--- django/db/models/loading.py (revision 11211)
102+++ django/db/models/loading.py (working copy)
103@@ -122,7 +122,7 @@
104                             return None
105                     else:
106                         return mod
107-            raise ImproperlyConfigured, "App with label %s could not be found" % app_label
108+            raise ImproperlyConfigured, "App with label %s could not be found or caused an error during import" % app_label
109         finally:
110             self.write_lock.release()
111