Skip to content

Commit

Permalink
Clean up temporary install roots after tests
Browse files Browse the repository at this point in the history
  • Loading branch information
scfc authored and m-blaha committed Jan 26, 2022
1 parent 96d48e8 commit 1a4406c
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions tests/test_system_upgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,19 +251,20 @@ def tearDown(self):
class CommandTestCaseBase(unittest.TestCase):
def setUp(self):
self.datadir = tempfile.mkdtemp(prefix="system_upgrade_test_datadir-")
self.installroot = tempfile.mkdtemp(prefix="system_upgrade_test_installroot-")
self.installroot = tempfile.TemporaryDirectory(prefix="system_upgrade_test_installroot-")
system_upgrade.SystemUpgradeCommand.DATADIR = self.datadir
self.cli = mock.MagicMock()
# the installroot is not strictly necessary for the test, but
# releasever detection is accessing host system files without it, and
# this fails on permissions in COPR srpm builds (e.g. from rpm-gitoverlay)
self.cli.base.conf.installroot = self.installroot
self.cli.base.conf.installroot = self.installroot.name
self.command = system_upgrade.SystemUpgradeCommand(cli=self.cli)
self.command.base.conf.cachedir = os.path.join(self.datadir, "cache")
self.command.base.conf.destdir = None

def tearDown(self):
shutil.rmtree(self.datadir)
self.installroot.cleanup()


class CommandTestCase(CommandTestCaseBase):
Expand Down

0 comments on commit 1a4406c

Please sign in to comment.