← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~cjwatson/launchpad:package-upload-test-isolation into launchpad:master

 

Colin Watson has proposed merging ~cjwatson/launchpad:package-upload-test-isolation into launchpad:master.

Commit message:
Remove PPA root in PackageUploadTestCase.tearDown

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)
Related bugs:
  Bug #1860011 in Launchpad itself: "test_publish_custom_marks_suite_dirty is an unreliable test"
  https://bugs.launchpad.net/launchpad/+bug/1860011

For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/377767

Without this, we have test isolation failures between multiple runs of PackageUploadTestCase, since the PPA root from the previous run is left lying around.

LP: #1860011
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:package-upload-test-isolation into launchpad:master.
diff --git a/lib/lp/soyuz/tests/test_packageupload.py b/lib/lp/soyuz/tests/test_packageupload.py
index 5f78fe2..cb4d038 100644
--- a/lib/lp/soyuz/tests/test_packageupload.py
+++ b/lib/lp/soyuz/tests/test_packageupload.py
@@ -1,4 +1,4 @@
-# Copyright 2009-2018 Canonical Ltd.  This software is licensed under the
+# Copyright 2009-2020 Canonical Ltd.  This software is licensed under the
 # GNU Affero General Public License version 3 (see the file LICENSE).
 
 """Test Build features."""
@@ -7,6 +7,8 @@ from __future__ import absolute_import, print_function, unicode_literals
 
 from datetime import timedelta
 import io
+import os.path
+import shutil
 from urllib2 import urlopen
 
 from debian.deb822 import Changes
@@ -84,6 +86,11 @@ class PackageUploadTestCase(TestCaseWithFactory):
         super(PackageUploadTestCase, self).setUp()
         self.test_publisher = SoyuzTestPublisher()
 
+    def tearDown(self):
+        super(PackageUploadTestCase, self).tearDown()
+        if os.path.exists(config.personalpackagearchive.root):
+            shutil.rmtree(config.personalpackagearchive.root)
+
     def test_realiseUpload_for_overridden_component_archive(self):
         # If the component of an upload is overridden to 'Partner' for
         # example, then the new publishing record should be for the