Commits

Anonymous committed 15d08d6

Moved calls to addCleanup before assertions in admin_scripts tests, so that cleanup occurs even when tests fails.

Comments (0)

Files changed (1)

tests/regressiontests/admin_scripts/tests.py

         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))
-        self.addCleanup(shutil.rmtree, testproject_dir)
 
         # running again..
         out, err = self.run_django_admin(args)
         testproject_dir = os.path.join(test_dir, 'othertestproject')
 
         out, err = self.run_django_admin(args)
+        self.addCleanup(shutil.rmtree, testproject_dir)
         self.assertNoOutput(err)
         self.assertTrue(os.path.isdir(os.path.join(testproject_dir, 'testproject')))
         self.assertTrue(os.path.exists(os.path.join(testproject_dir, 'testproject', 'manage.py')))
-        self.addCleanup(shutil.rmtree, testproject_dir)
 
         # running again..
         out, err = self.run_django_admin(args)
         testproject_dir = os.path.join(test_dir, 'customtestproject')
 
         out, err = self.run_django_admin(args)
+        self.addCleanup(shutil.rmtree, testproject_dir)
         self.assertNoOutput(err)
         self.assertTrue(os.path.isdir(testproject_dir))
-        self.addCleanup(shutil.rmtree, testproject_dir)
         self.assertTrue(os.path.exists(os.path.join(testproject_dir, 'additional_dir')))
 
     def test_custom_project_template_from_tarball_by_path(self):
         testproject_dir = os.path.join(test_dir, 'tarballtestproject')
 
         out, err = self.run_django_admin(args)
+        self.addCleanup(shutil.rmtree, testproject_dir)
         self.assertNoOutput(err)
         self.assertTrue(os.path.isdir(testproject_dir))
-        self.addCleanup(shutil.rmtree, testproject_dir)
         self.assertTrue(os.path.exists(os.path.join(testproject_dir, 'run.py')))
 
     def test_custom_project_template_from_tarball_by_url(self):
         testproject_dir = os.path.join(test_dir, 'urltestproject')
 
         out, err = self.run_django_admin(args)
+        self.addCleanup(shutil.rmtree, testproject_dir)
         self.assertNoOutput(err)
         self.assertTrue(os.path.isdir(testproject_dir))
-        self.addCleanup(shutil.rmtree, testproject_dir)
         self.assertTrue(os.path.exists(os.path.join(testproject_dir, 'run.py')))