From 74737da1ab9b5a25c38616d563a973af267277f7 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Fri, 20 May 2022 06:26:50 -0400 Subject: tests: switch to tempfile.TemporaryDirectory Now that we don't need to support Python 2, we can switch to this API for better contextmanager logic. Change-Id: I2d03e391121886547e7808a3b5c3b470c411533f Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/337515 Reviewed-by: LaMont Jones Tested-by: Mike Frysinger --- tests/test_manifest_xml.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'tests/test_manifest_xml.py') diff --git a/tests/test_manifest_xml.py b/tests/test_manifest_xml.py index ede41547..85c20733 100644 --- a/tests/test_manifest_xml.py +++ b/tests/test_manifest_xml.py @@ -17,7 +17,6 @@ import os import platform import re -import shutil import tempfile import unittest import xml.dom.minidom @@ -92,7 +91,8 @@ class ManifestParseTestCase(unittest.TestCase): """TestCase for parsing manifests.""" def setUp(self): - self.tempdir = tempfile.mkdtemp(prefix='repo_tests') + self.tempdirobj = tempfile.TemporaryDirectory(prefix='repo_tests') + self.tempdir = self.tempdirobj.name self.repodir = os.path.join(self.tempdir, '.repo') self.manifest_dir = os.path.join(self.repodir, 'manifests') self.manifest_file = os.path.join( @@ -111,7 +111,7 @@ class ManifestParseTestCase(unittest.TestCase): """) def tearDown(self): - shutil.rmtree(self.tempdir, ignore_errors=True) + self.tempdirobj.cleanup() def getXmlManifest(self, data): """Helper to initialize a manifest for testing.""" -- cgit v1.2.3-54-g00ecf