test_fakedbapi: use tempdir for config paths
authorZac Medico <zmedico@gentoo.org>
Sat, 11 Jun 2011 02:17:10 +0000 (19:17 -0700)
committerZac Medico <zmedico@gentoo.org>
Sat, 11 Jun 2011 02:17:10 +0000 (19:17 -0700)
pym/portage/tests/dbapi/test_fakedbapi.py

index ed24782ebda672992fccbd54dfee83ae2b62da59..d1ea32d53d6fc1a396f78ff373ce84b360a379e1 100644 (file)
@@ -1,6 +1,9 @@
 # Copyright 2011 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
+import shutil
+import tempfile
+
 from portage.dbapi.virtual import fakedbapi
 from portage.package.ebuild.config import config
 from portage.tests import TestCase
@@ -33,10 +36,14 @@ class TestFakedbapi(TestCase):
                        ("virtual/package-manager",             ["virtual/package-manager-0"]),
                )
 
-               fakedb = fakedbapi(settings=config(config_profile_path=""))
-               for cpv, metadata in packages:
-                       fakedb.cpv_inject(cpv, metadata=metadata)
+               tempdir = tempfile.mkdtemp()
+               try:
+                       fakedb = fakedbapi(settings=config(config_profile_path="",
+                               config_root=tempdir, target_root=tempdir))
+                       for cpv, metadata in packages:
+                               fakedb.cpv_inject(cpv, metadata=metadata)
 
-               for atom, expected_result in match_tests:
-                       result = []
-                       self.assertEqual( fakedb.match(atom), expected_result )
+                       for atom, expected_result in match_tests:
+                               self.assertEqual( fakedb.match(atom), expected_result )
+               finally:
+                       shutil.rmtree(tempdir)