diff options
author | Mike Frysinger <vapier@google.com> | 2022-05-20 06:26:50 -0400 |
---|---|---|
committer | Mike Frysinger <vapier@google.com> | 2022-05-20 11:38:10 +0000 |
commit | 74737da1ab9b5a25c38616d563a973af267277f7 (patch) | |
tree | 23b1758d149942868de03eed6b27c57bbdf9ce51 /tests/test_manifest_xml.py | |
parent | 0ddb6776110aaefee3f93cc171d11dcdc12d082b (diff) | |
download | git-repo-74737da1ab9b5a25c38616d563a973af267277f7.tar.gz |
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 <lamontjones@google.com>
Tested-by: Mike Frysinger <vapier@google.com>
Diffstat (limited to 'tests/test_manifest_xml.py')
-rw-r--r-- | tests/test_manifest_xml.py | 6 |
1 files changed, 3 insertions, 3 deletions
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 @@ | |||
17 | import os | 17 | import os |
18 | import platform | 18 | import platform |
19 | import re | 19 | import re |
20 | import shutil | ||
21 | import tempfile | 20 | import tempfile |
22 | import unittest | 21 | import unittest |
23 | import xml.dom.minidom | 22 | import xml.dom.minidom |
@@ -92,7 +91,8 @@ class ManifestParseTestCase(unittest.TestCase): | |||
92 | """TestCase for parsing manifests.""" | 91 | """TestCase for parsing manifests.""" |
93 | 92 | ||
94 | def setUp(self): | 93 | def setUp(self): |
95 | self.tempdir = tempfile.mkdtemp(prefix='repo_tests') | 94 | self.tempdirobj = tempfile.TemporaryDirectory(prefix='repo_tests') |
95 | self.tempdir = self.tempdirobj.name | ||
96 | self.repodir = os.path.join(self.tempdir, '.repo') | 96 | self.repodir = os.path.join(self.tempdir, '.repo') |
97 | self.manifest_dir = os.path.join(self.repodir, 'manifests') | 97 | self.manifest_dir = os.path.join(self.repodir, 'manifests') |
98 | self.manifest_file = os.path.join( | 98 | self.manifest_file = os.path.join( |
@@ -111,7 +111,7 @@ class ManifestParseTestCase(unittest.TestCase): | |||
111 | """) | 111 | """) |
112 | 112 | ||
113 | def tearDown(self): | 113 | def tearDown(self): |
114 | shutil.rmtree(self.tempdir, ignore_errors=True) | 114 | self.tempdirobj.cleanup() |
115 | 115 | ||
116 | def getXmlManifest(self, data): | 116 | def getXmlManifest(self, data): |
117 | """Helper to initialize a manifest for testing.""" | 117 | """Helper to initialize a manifest for testing.""" |