launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #27877
[Merge] ~cjwatson/lpcraft:plugin-test-isolation into lpcraft:main
Colin Watson has proposed merging ~cjwatson/lpcraft:plugin-test-isolation into lpcraft:main.
Commit message:
Fix isolation of TestPlugins
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~cjwatson/lpcraft/+git/lpcraft/+merge/413627
`TestPlugins` wrote to `.launchpad.yaml` without changing to a temporary directory first, which caused it to modify the source tree.
--
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/lpcraft:plugin-test-isolation into lpcraft:main.
diff --git a/lpcraft/plugin/tests/test_plugins.py b/lpcraft/plugin/tests/test_plugins.py
index b833b60..af5c0f3 100644
--- a/lpcraft/plugin/tests/test_plugins.py
+++ b/lpcraft/plugin/tests/test_plugins.py
@@ -1,12 +1,14 @@
# Copyright 2021 Canonical Ltd. This software is licensed under the
# GNU General Public License version 3 (see the file LICENSE).
+import os
import subprocess
from pathlib import Path, PosixPath
from textwrap import dedent
from unittest.mock import ANY, Mock, call, patch
from craft_providers.lxd import LXC, launch
+from fixtures import TempDir
from lpcraft.commands.tests import CommandBaseTestCase
from lpcraft.errors import ConfigurationError
@@ -15,6 +17,13 @@ from lpcraft.providers.tests import FakeLXDInstaller
class TestPlugins(CommandBaseTestCase):
+ def setUp(self):
+ super().setUp()
+ tempdir = Path(self.useFixture(TempDir()).path)
+ cwd = Path.cwd()
+ os.chdir(tempdir)
+ self.addCleanup(os.chdir, cwd)
+
def makeLXDProvider(
self,
is_ready=True,
Follow ups