Fix unit tests which modify the source tree. (#45763)

* Fix CNOS unit test log usage.
* Use temp dir for Galaxy unit tests.
* Write to temp files in interfaces_file unit test.
* Fix log placement in netapp_e_ldap unit test.
This commit is contained in:
Matt Clay
2018-09-17 20:27:14 -07:00
committed by GitHub
parent 0961d914d7
commit 0686450cae
9 changed files with 97 additions and 64 deletions

View File

@@ -21,6 +21,7 @@ __metaclass__ = type
import os
import json
import tempfile
from ansible.compat.tests import unittest
from ansible.compat.tests.mock import patch
@@ -59,6 +60,15 @@ class AnsibleFailJson(Exception):
class TestCnosModule(unittest.TestCase):
def setUp(self):
super(TestCnosModule, self).setUp()
self.test_log = tempfile.mkstemp(prefix='ansible-test-cnos-module-', suffix='.log')[1]
def tearDown(self):
super(TestCnosModule, self).tearDown()
os.remove(self.test_log)
def execute_module(self, failed=False, changed=False, commands=None,
sort=True, defaults=False):