From f619ec3853e0cc6ac8dc16ad35d0b553c8c790c2 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Tue, 13 Dec 2016 01:42:49 +0100 Subject: [plugins] Make the test_glob_file_over_limit test reliable by using a tmpdir Originally,f there were other files matching the glob of /tmp/tmp* then the test would fail. By using a tmpdir, we make sure that we know what files to expect. Signed-off-by: Michael Adam --- tests/plugin_tests.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/plugin_tests.py b/tests/plugin_tests.py index ae8db065..531f3508 100644 --- a/tests/plugin_tests.py +++ b/tests/plugin_tests.py @@ -1,6 +1,7 @@ import unittest import os import tempfile +import shutil # PYCOMPAT import six @@ -269,16 +270,15 @@ class AddCopySpecTests(unittest.TestCase): def test_glob_file_over_limit(self): self.mp.sysroot = '/' - # assume these are in /tmp - fn = create_file(2) - fn2 = create_file(2) - self.mp.add_copy_spec_limit("/tmp/tmp*", 1) + tmpdir = tempfile.mkdtemp() + fn = create_file(2, dir=tmpdir) + fn2 = create_file(2, dir=tmpdir) + self.mp.add_copy_spec_limit(tmpdir + "/*", 1) self.assertEquals(len(self.mp.copy_strings), 1) content, fname = self.mp.copy_strings[0] self.assertTrue("tailed" in fname) self.assertEquals(1024 * 1024, len(content)) - os.unlink(fn) - os.unlink(fn2) + shutil.rmtree(tmpdir) class CheckEnabledTests(unittest.TestCase): -- cgit