Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #7715 -- Modified the admin_scripts tests to do an app level im…

…port, rather than a project level import. This removes the potential for conflict between the admin script tests and the settings for the test suite itself. Thanks to Malcolm Tredinnick for his help hunting this one down.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@7887 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 4516233f9ef3048735f85703f8dc515160e79de4 1 parent c742afb
Russell Keith-Magee authored July 11, 2008
78  tests/regressiontests/admin_scripts/tests.py
@@ -29,7 +29,7 @@ def write_settings(self, filename, apps=None):
29 29
                 settings_file.write("%s = '%s'\n" % (s, str(getattr(settings,s))))
30 30
                 
31 31
         if apps is None:
32  
-            apps = ['django.contrib.auth', 'django.contrib.contenttypes', 'regressiontests.admin_scripts']
  32
+            apps = ['django.contrib.auth', 'django.contrib.contenttypes', 'admin_scripts']
33 33
 
34 34
         if apps:
35 35
             settings_file.write("INSTALLED_APPS = %s\n" % apps)
@@ -66,8 +66,8 @@ def run_test(self, script, args, settings_file=None, apps=None):
66 66
         elif 'DJANGO_SETTINGS_MODULE' in os.environ:
67 67
             del os.environ['DJANGO_SETTINGS_MODULE']
68 68
         
69  
-        os.environ['PYTHONPATH'] = os.pathsep.join([project_dir,base_dir])
70  
-        
  69
+        os.environ['PYTHONPATH'] = os.pathsep.join([test_dir,base_dir])
  70
+
71 71
         # Move to the test directory and run
72 72
         os.chdir(test_dir)
73 73
         stdin, stdout, stderr = os.popen3(cmd)
@@ -129,17 +129,17 @@ def test_builtin_command(self):
129 129
                 
130 130
     def test_builtin_with_bad_settings(self):
131 131
         "no settings: django-admin builtin commands fail if settings file (from argument) doesn't exist"
132  
-        args = ['sqlall','--settings=regressiontests.bad_settings', 'admin_scripts']
  132
+        args = ['sqlall','--settings=bad_settings', 'admin_scripts']
133 133
         out, err = self.run_django_admin(args)
134 134
         self.assertNoOutput(out)
135  
-        self.assertOutput(err, "Could not import settings 'regressiontests.bad_settings'")
  135
+        self.assertOutput(err, "Could not import settings 'bad_settings'")
136 136
 
137 137
     def test_builtin_with_bad_environment(self):
138 138
         "no settings: django-admin builtin commands fail if settings file (from environment) doesn't exist"
139 139
         args = ['sqlall','admin_scripts']
140  
-        out, err = self.run_django_admin(args,'regressiontests.bad_settings')
  140
+        out, err = self.run_django_admin(args,'bad_settings')
141 141
         self.assertNoOutput(out)
142  
-        self.assertOutput(err, "Could not import settings 'regressiontests.bad_settings'")
  142
+        self.assertOutput(err, "Could not import settings 'bad_settings'")
143 143
 
144 144
 
145 145
 class DjangoAdminDefaultSettings(AdminScriptTestCase):
@@ -161,7 +161,7 @@ def test_builtin_command(self):
161 161
         
162 162
     def test_builtin_with_settings(self):
163 163
         "default: django-admin builtin commands succeed if settings are provided as argument"
164  
-        args = ['sqlall','--settings=regressiontests.settings', 'admin_scripts']
  164
+        args = ['sqlall','--settings=settings', 'admin_scripts']
165 165
         out, err = self.run_django_admin(args)
166 166
         self.assertNoOutput(err)
167 167
         self.assertOutput(out, 'CREATE TABLE')
@@ -169,23 +169,23 @@ def test_builtin_with_settings(self):
169 169
     def test_builtin_with_environment(self):
170 170
         "default: django-admin builtin commands succeed if settings are provided in the environment"
171 171
         args = ['sqlall','admin_scripts']
172  
-        out, err = self.run_django_admin(args,'regressiontests.settings')
  172
+        out, err = self.run_django_admin(args,'settings')
173 173
         self.assertNoOutput(err)
174 174
         self.assertOutput(out, 'CREATE TABLE')
175 175
 
176 176
     def test_builtin_with_bad_settings(self):
177 177
         "default: django-admin builtin commands fail if settings file (from argument) doesn't exist"
178  
-        args = ['sqlall','--settings=regressiontests.bad_settings', 'admin_scripts']
  178
+        args = ['sqlall','--settings=bad_settings', 'admin_scripts']
179 179
         out, err = self.run_django_admin(args)
180 180
         self.assertNoOutput(out)
181  
-        self.assertOutput(err, "Could not import settings 'regressiontests.bad_settings'")
  181
+        self.assertOutput(err, "Could not import settings 'bad_settings'")
182 182
 
183 183
     def test_builtin_with_bad_environment(self):
184 184
         "default: django-admin builtin commands fail if settings file (from environment) doesn't exist"
185 185
         args = ['sqlall','admin_scripts']
186  
-        out, err = self.run_django_admin(args,'regressiontests.bad_settings')
  186
+        out, err = self.run_django_admin(args,'bad_settings')
187 187
         self.assertNoOutput(out)
188  
-        self.assertOutput(err, "Could not import settings 'regressiontests.bad_settings'")
  188
+        self.assertOutput(err, "Could not import settings 'bad_settings'")
189 189
 
190 190
     def test_custom_command(self):
191 191
         "default: django-admin can't execute user commands"
@@ -196,7 +196,7 @@ def test_custom_command(self):
196 196
             
197 197
     def test_custom_command_with_settings(self):
198 198
         "default: django-admin can't execute user commands, even if settings are provided as argument"
199  
-        args = ['noargs_command', '--settings=regressiontests.settings']
  199
+        args = ['noargs_command', '--settings=settings']
200 200
         out, err = self.run_django_admin(args)
201 201
         self.assertNoOutput(out)
202 202
         self.assertOutput(err, "Unknown command: 'noargs_command'")
@@ -204,7 +204,7 @@ def test_custom_command_with_settings(self):
204 204
     def test_custom_command_with_environment(self):
205 205
         "default: django-admin can't execute user commands, even if settings are provided in environment"
206 206
         args = ['noargs_command']
207  
-        out, err = self.run_django_admin(args,'regressiontests.settings')
  207
+        out, err = self.run_django_admin(args,'settings')
208 208
         self.assertNoOutput(out)
209 209
         self.assertOutput(err, "Unknown command: 'noargs_command'")
210 210
 
@@ -227,7 +227,7 @@ def test_builtin_command(self):
227 227
         
228 228
     def test_builtin_with_settings(self):
229 229
         "minimal: django-admin builtin commands fail if settings are provided as argument"
230  
-        args = ['sqlall','--settings=regressiontests.settings', 'admin_scripts']
  230
+        args = ['sqlall','--settings=settings', 'admin_scripts']
231 231
         out, err = self.run_django_admin(args)
232 232
         self.assertNoOutput(out)
233 233
         self.assertOutput(err, 'App with label admin_scripts could not be found')
@@ -235,23 +235,23 @@ def test_builtin_with_settings(self):
235 235
     def test_builtin_with_environment(self):
236 236
         "minimal: django-admin builtin commands fail if settings are provided in the environment"
237 237
         args = ['sqlall','admin_scripts']
238  
-        out, err = self.run_django_admin(args,'regressiontests.settings')
  238
+        out, err = self.run_django_admin(args,'settings')
239 239
         self.assertNoOutput(out)
240 240
         self.assertOutput(err, 'App with label admin_scripts could not be found')
241 241
 
242 242
     def test_builtin_with_bad_settings(self):
243 243
         "minimal: django-admin builtin commands fail if settings file (from argument) doesn't exist"
244  
-        args = ['sqlall','--settings=regressiontests.bad_settings', 'admin_scripts']
  244
+        args = ['sqlall','--settings=bad_settings', 'admin_scripts']
245 245
         out, err = self.run_django_admin(args)
246 246
         self.assertNoOutput(out)
247  
-        self.assertOutput(err, "Could not import settings 'regressiontests.bad_settings'")
  247
+        self.assertOutput(err, "Could not import settings 'bad_settings'")
248 248
 
249 249
     def test_builtin_with_bad_environment(self):
250 250
         "minimal: django-admin builtin commands fail if settings file (from environment) doesn't exist"
251 251
         args = ['sqlall','admin_scripts']
252  
-        out, err = self.run_django_admin(args,'regressiontests.bad_settings')
  252
+        out, err = self.run_django_admin(args,'bad_settings')
253 253
         self.assertNoOutput(out)
254  
-        self.assertOutput(err, "Could not import settings 'regressiontests.bad_settings'")
  254
+        self.assertOutput(err, "Could not import settings 'bad_settings'")
255 255
             
256 256
     def test_custom_command(self):
257 257
         "minimal: django-admin can't execute user commands"
@@ -262,7 +262,7 @@ def test_custom_command(self):
262 262
             
263 263
     def test_custom_command_with_settings(self):
264 264
         "minimal: django-admin can't execute user commands, even if settings are provided as argument"
265  
-        args = ['noargs_command', '--settings=regressiontests.settings']
  265
+        args = ['noargs_command', '--settings=settings']
266 266
         out, err = self.run_django_admin(args)
267 267
         self.assertNoOutput(out)
268 268
         self.assertOutput(err, "Unknown command: 'noargs_command'")
@@ -270,7 +270,7 @@ def test_custom_command_with_settings(self):
270 270
     def test_custom_command_with_environment(self):
271 271
         "minimal: django-admin can't execute user commands, even if settings are provided in environment"
272 272
         args = ['noargs_command']
273  
-        out, err = self.run_django_admin(args,'regressiontests.settings')
  273
+        out, err = self.run_django_admin(args,'settings')
274 274
         self.assertNoOutput(out)
275 275
         self.assertOutput(err, "Unknown command: 'noargs_command'")
276 276
 
@@ -293,7 +293,7 @@ def test_builtin_command(self):
293 293
 
294 294
     def test_builtin_with_settings(self):
295 295
         "alternate: django-admin builtin commands succeed if settings are provided as argument"
296  
-        args = ['sqlall','--settings=regressiontests.alternate_settings', 'admin_scripts']
  296
+        args = ['sqlall','--settings=alternate_settings', 'admin_scripts']
297 297
         out, err = self.run_django_admin(args)
298 298
         self.assertNoOutput(err)
299 299
         self.assertOutput(out, 'CREATE TABLE')
@@ -301,23 +301,23 @@ def test_builtin_with_settings(self):
301 301
     def test_builtin_with_environment(self):
302 302
         "alternate: django-admin builtin commands succeed if settings are provided in the environment"
303 303
         args = ['sqlall','admin_scripts']
304  
-        out, err = self.run_django_admin(args,'regressiontests.alternate_settings')
  304
+        out, err = self.run_django_admin(args,'alternate_settings')
305 305
         self.assertNoOutput(err)
306 306
         self.assertOutput(out, 'CREATE TABLE')
307 307
 
308 308
     def test_builtin_with_bad_settings(self):
309 309
         "alternate: django-admin builtin commands fail if settings file (from argument) doesn't exist"
310  
-        args = ['sqlall','--settings=regressiontests.bad_settings', 'admin_scripts']
  310
+        args = ['sqlall','--settings=bad_settings', 'admin_scripts']
311 311
         out, err = self.run_django_admin(args)
312 312
         self.assertNoOutput(out)
313  
-        self.assertOutput(err, "Could not import settings 'regressiontests.bad_settings'")
  313
+        self.assertOutput(err, "Could not import settings 'bad_settings'")
314 314
 
315 315
     def test_builtin_with_bad_environment(self):
316 316
         "alternate: django-admin builtin commands fail if settings file (from environment) doesn't exist"
317 317
         args = ['sqlall','admin_scripts']
318  
-        out, err = self.run_django_admin(args,'regressiontests.bad_settings')
  318
+        out, err = self.run_django_admin(args,'bad_settings')
319 319
         self.assertNoOutput(out)
320  
-        self.assertOutput(err, "Could not import settings 'regressiontests.bad_settings'")
  320
+        self.assertOutput(err, "Could not import settings 'bad_settings'")
321 321
 
322 322
     def test_custom_command(self):
323 323
         "alternate: django-admin can't execute user commands"
@@ -328,7 +328,7 @@ def test_custom_command(self):
328 328
 
329 329
     def test_custom_command_with_settings(self):
330 330
         "alternate: django-admin can't execute user commands, even if settings are provided as argument"
331  
-        args = ['noargs_command', '--settings=regressiontests.alternate_settings']
  331
+        args = ['noargs_command', '--settings=alternate_settings']
332 332
         out, err = self.run_django_admin(args)
333 333
         self.assertNoOutput(out)
334 334
         self.assertOutput(err, "Unknown command: 'noargs_command'")
@@ -336,7 +336,7 @@ def test_custom_command_with_settings(self):
336 336
     def test_custom_command_with_environment(self):
337 337
         "alternate: django-admin can't execute user commands, even if settings are provided in environment"
338 338
         args = ['noargs_command']
339  
-        out, err = self.run_django_admin(args,'regressiontests.alternate_settings')
  339
+        out, err = self.run_django_admin(args,'alternate_settings')
340 340
         self.assertNoOutput(out)
341 341
         self.assertOutput(err, "Unknown command: 'noargs_command'")
342 342
 
@@ -364,7 +364,7 @@ def test_builtin_command(self):
364 364
 
365 365
     def test_builtin_with_settings(self):
366 366
         "alternate: django-admin builtin commands succeed if settings are provided as argument"
367  
-        args = ['sqlall','--settings=regressiontests.alternate_settings', 'admin_scripts']
  367
+        args = ['sqlall','--settings=alternate_settings', 'admin_scripts']
368 368
         out, err = self.run_django_admin(args)
369 369
         self.assertNoOutput(err)
370 370
         self.assertOutput(out, 'CREATE TABLE')
@@ -372,22 +372,22 @@ def test_builtin_with_settings(self):
372 372
     def test_builtin_with_environment(self):
373 373
         "alternate: django-admin builtin commands succeed if settings are provided in the environment"
374 374
         args = ['sqlall','admin_scripts']
375  
-        out, err = self.run_django_admin(args,'regressiontests.alternate_settings')
  375
+        out, err = self.run_django_admin(args,'alternate_settings')
376 376
         self.assertNoOutput(err)
377 377
         self.assertOutput(out, 'CREATE TABLE')
378 378
 
379 379
     def test_builtin_with_bad_settings(self):
380 380
         "alternate: django-admin builtin commands fail if settings file (from argument) doesn't exist"
381  
-        args = ['sqlall','--settings=regressiontests.bad_settings', 'admin_scripts']
  381
+        args = ['sqlall','--settings=bad_settings', 'admin_scripts']
382 382
         out, err = self.run_django_admin(args)
383  
-        self.assertOutput(err, "Could not import settings 'regressiontests.bad_settings'")
  383
+        self.assertOutput(err, "Could not import settings 'bad_settings'")
384 384
 
385 385
     def test_builtin_with_bad_environment(self):
386 386
         "alternate: django-admin builtin commands fail if settings file (from environment) doesn't exist"
387 387
         args = ['sqlall','admin_scripts']
388  
-        out, err = self.run_django_admin(args,'regressiontests.bad_settings')
  388
+        out, err = self.run_django_admin(args,'bad_settings')
389 389
         self.assertNoOutput(out)
390  
-        self.assertOutput(err, "Could not import settings 'regressiontests.bad_settings'")
  390
+        self.assertOutput(err, "Could not import settings 'bad_settings'")
391 391
 
392 392
     def test_custom_command(self):
393 393
         "alternate: django-admin can't execute user commands"
@@ -398,7 +398,7 @@ def test_custom_command(self):
398 398
 
399 399
     def test_custom_command_with_settings(self):
400 400
         "alternate: django-admin can't execute user commands, even if settings are provided as argument"
401  
-        args = ['noargs_command', '--settings=regressiontests.alternate_settings']
  401
+        args = ['noargs_command', '--settings=alternate_settings']
402 402
         out, err = self.run_django_admin(args)
403 403
         self.assertNoOutput(out)
404 404
         self.assertOutput(err, "Unknown command: 'noargs_command'")
@@ -406,7 +406,7 @@ def test_custom_command_with_settings(self):
406 406
     def test_custom_command_with_environment(self):
407 407
         "alternate: django-admin can't execute user commands, even if settings are provided in environment"
408 408
         args = ['noargs_command']
409  
-        out, err = self.run_django_admin(args,'regressiontests.alternate_settings')
  409
+        out, err = self.run_django_admin(args,'alternate_settings')
410 410
         self.assertNoOutput(out)
411 411
         self.assertOutput(err, "Unknown command: 'noargs_command'")
412 412
         

0 notes on commit 4516233

Please sign in to comment.
Something went wrong with that request. Please try again.