From b6bda2fe154d067084a99733f42663252ff9b399 Mon Sep 17 00:00:00 2001 From: Dan Radez Date: Mon, 19 Sep 2016 15:06:43 -0400 Subject: Handling file loads and tmp dirs differently Change-Id: I602279b30b035cfc667e4ee9b83905a638440abb Signed-off-by: Dan Radez --- tests/test_apex_deploy_settings.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'tests/test_apex_deploy_settings.py') 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 -- cgit 1.2.3-korg