aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Adam <obnox@samba.org>2016-12-13 01:42:49 +0100
committerBryn M. Reeves <bmr@redhat.com>2017-03-28 14:12:07 +0100
commitf619ec3853e0cc6ac8dc16ad35d0b553c8c790c2 (patch)
tree2bb44549e97ea9a5bab1f2d75e13615f6960af21
parente12cc14c9bd8af5c03050de6c1934d52c566958f (diff)
downloadsos-f619ec3853e0cc6ac8dc16ad35d0b553c8c790c2.tar.gz
[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 <obnox@samba.org>
-rw-r--r--tests/plugin_tests.py12
1 files 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):