From a082e60d36af81d908e1fa185032c5da1e270375 Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Thu, 5 Aug 2010 13:33:38 -0700 Subject: [PATCH] Use a ResolverPlayground.cleanup() method to cleanup temporary directories. --- pym/portage/tests/resolver/ResolverPlayground.py | 4 ++++ pym/portage/tests/resolver/test_eapi.py | 12 ++++++++---- pym/portage/tests/resolver/test_simple.py | 12 ++++++++---- 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/pym/portage/tests/resolver/ResolverPlayground.py b/pym/portage/tests/resolver/ResolverPlayground.py index 643a3b611..9034deb88 100644 --- a/pym/portage/tests/resolver/ResolverPlayground.py +++ b/pym/portage/tests/resolver/ResolverPlayground.py @@ -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) diff --git a/pym/portage/tests/resolver/test_eapi.py b/pym/portage/tests/resolver/test_eapi.py index f2eff44d4..19c7b2193 100644 --- a/pym/portage/tests/resolver/test_eapi.py +++ b/pym/portage/tests/resolver/test_eapi.py @@ -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() diff --git a/pym/portage/tests/resolver/test_simple.py b/pym/portage/tests/resolver/test_simple.py index c092129b7..0e77c9e6d 100644 --- a/pym/portage/tests/resolver/test_simple.py +++ b/pym/portage/tests/resolver/test_simple.py @@ -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() -- 2.26.2