[PATCH] Clean up after processKickstart in parse-kickstart_test.py.

Brian C. Lane bcl at redhat.com
Fri May 15 16:07:08 UTC 2015


On Fri, May 15, 2015 at 11:52:45AM -0400, Chris Lumens wrote:
> It's the responsibility of whoever calls processKickstart to clean up the
> temp file afterwards, if it's no longer needed.  dracut/parse-kickstart does
> the call, but the temp file is needed to be passed to anaconda.  Thus it
> can't do the cleanup.  The test must therefore do so.
> 
> Also, each test should be its own function to ensure it gets cleaned up
> after.  tearDown only gets called once per class, so it will only clean up
> one file.
> ---
>  tests/dracut_tests/parse-kickstart_test.py | 16 ++++++++++++++--
>  1 file changed, 14 insertions(+), 2 deletions(-)
> 
> diff --git a/tests/dracut_tests/parse-kickstart_test.py b/tests/dracut_tests/parse-kickstart_test.py
> index b8fdac7..f076001 100644
> --- a/tests/dracut_tests/parse-kickstart_test.py
> +++ b/tests/dracut_tests/parse-kickstart_test.py
> @@ -31,8 +31,16 @@ class BaseTestCase(unittest.TestCase):
>      def tearDown(self):
>          # remove the testing directory
>          if self.tmpdir and os.path.isdir(self.tmpdir):
> -            shutil.rmtree(self.tmpdir)
> +            try:
> +                with open(self.tmpdir + "/ks.info") as f:
> +                    for line in f:
> +                        if line.startswith("parsed_kickstart="):
> +                            os.remove(line[18:-2])

I'd do:

os.remove(line.partition("=")[2])

to make it less sensitive to character count.

ACK.

-- 
Brian C. Lane | Anaconda Team | IRC: bcl #anaconda | Port Orchard, WA (PST8PDT)


More information about the anaconda-patches mailing list