Use a ResolverPlayground.cleanup() method to cleanup temporary directories.
authorZac Medico <zmedico@gentoo.org>
Thu, 5 Aug 2010 20:33:38 +0000 (13:33 -0700)
committerZac Medico <zmedico@gentoo.org>
Thu, 5 Aug 2010 20:37:33 +0000 (13:37 -0700)
pym/portage/tests/resolver/ResolverPlayground.py
pym/portage/tests/resolver/test_eapi.py
pym/portage/tests/resolver/test_simple.py

index 643a3b6112d6ed2c9f17624283c677a40a7a6947..9034deb88cdcb4305dd0284d7e352d4a1181b400 100644 (file)
@@ -2,6 +2,7 @@
 # Distributed under the terms of the GNU General Public License v2
 
 from itertools import chain
+import shutil
 import tempfile
 import portage
 from portage import os
@@ -192,3 +193,6 @@ class ResolverPlayground(object):
                else:
                        #TODO: Use mydepgraph.display_problems() to return a useful error message
                        return False, None
+
+       def cleanup(self):
+               shutil.rmtree(self.root)
index f2eff44d47e3c7e72dba15f7eadc801be8c1dfcb..19c7b219304bdd9e7419a85315717a066f69a63a 100644 (file)
@@ -92,7 +92,11 @@ class SimpleResolverTestCase(TestCase):
                        )
 
                playground = ResolverPlayground(ebuilds=ebuilds)
-
-               for atoms, options, action, expected_result, expected_mergelist in requests:
-                       success, mergelist = playground.run(atoms, options, action)
-                       self.assertEqual((success, mergelist), (expected_result, expected_mergelist))
+               try:
+                       for atoms, options, action, \
+                               expected_result, expected_mergelist in requests:
+                               success, mergelist = playground.run(atoms, options, action)
+                               self.assertEqual((success, mergelist),
+                                       (expected_result, expected_mergelist))
+               finally:
+                       playground.cleanup()
index c092129b7879db9a4893a95a9428417ebae40f04..0e77c9e6d0c0da614c02a5cd7ba3cf437572f73c 100644 (file)
@@ -24,7 +24,11 @@ class SimpleResolverTestCase(TestCase):
                        )
 
                playground = ResolverPlayground(ebuilds=ebuilds, installed=installed)
-
-               for atoms, options, action, expected_result, expected_mergelist in requests:
-                       success, mergelist = playground.run(atoms, options, action)
-                       self.assertEqual((success, mergelist), (expected_result, expected_mergelist))
+               try:
+                       for atoms, options, action, \
+                               expected_result, expected_mergelist in requests:
+                               success, mergelist = playground.run(atoms, options, action)
+                               self.assertEqual((success, mergelist),
+                                       (expected_result, expected_mergelist))
+               finally:
+                       playground.cleanup()