summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorDan Radez <dradez@redhat.com>2016-09-19 15:06:43 -0400
committerDan Radez <dradez@redhat.com>2016-09-20 14:24:17 -0400
commitb6bda2fe154d067084a99733f42663252ff9b399 (patch)
tree17f614866d74c4c805373967cef0a837bf8c0ccc /tests
parent58bc90d143303c1f9d4e9f174294f71dfa8303d6 (diff)
Handling file loads and tmp dirs differently
Change-Id: I602279b30b035cfc667e4ee9b83905a638440abb Signed-off-by: Dan Radez <dradez@redhat.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/test_apex_deploy_settings.py16
-rw-r--r--tests/test_apex_python_utils_py.py5
2 files changed, 15 insertions, 6 deletions
diff --git a/tests/test_apex_deploy_settings.py b/tests/test_apex_deploy_settings.py
index 1e26b287..2af187b2 100644
--- a/tests/test_apex_deploy_settings.py
+++ b/tests/test_apex_deploy_settings.py
@@ -7,8 +7,9 @@
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
-import io
# https://docs.python.org/3/library/io.html
+import io
+import tempfile
from apex.deploy_settings import DeploySettings
from apex.deploy_settings import DeploySettingsException
@@ -84,11 +85,14 @@ class TestIpUtils(object):
def test__validate_settings(self):
for c in test_deploy_content:
- f = open('/tmp/apex_deploy_test_file', 'w')
- f.write(c)
- f.close()
- assert_raises(DeploySettingsException,
- DeploySettings, '/tmp/apex_deploy_test_file')
+ try:
+ f = tempfile.NamedTemporaryFile(mode='w')
+ f.write(c)
+ f.flush()
+ assert_raises(DeploySettingsException,
+ DeploySettings, f.name)
+ finally:
+ f.close()
def test_dump_bash(self):
# the performance file has the most use of the function
diff --git a/tests/test_apex_python_utils_py.py b/tests/test_apex_python_utils_py.py
index 237c5589..28180f06 100644
--- a/tests/test_apex_python_utils_py.py
+++ b/tests/test_apex_python_utils_py.py
@@ -7,7 +7,9 @@
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
+import shutil
import sys
+import tempfile
from test_apex_ip_utils import get_default_gateway_linux
from apex_python_utils import main
@@ -57,11 +59,14 @@ class TestCommonUtils(object):
assert_equal(main(), None)
def test_parse_net_settings(self):
+ tmp_dir = tempfile.mkdtemp()
args = self.parser.parse_args(['parse-net-settings',
'-s', net_sets,
'--flat',
+ '-td', tmp_dir,
'-e', net_env])
assert_equal(parse_net_settings(args), None)
+ shutil.rmtree(tmp_dir, ignore_errors=True)
def test_parse_deploy_settings(self):
args = self.parser.parse_args(['parse-deploy-settings',