From e575f655c19a390513d19f28b3b779a2d3a5606e Mon Sep 17 00:00:00 2001 From: Nathaniel Case Date: Wed, 12 Sep 2018 12:17:29 -0400 Subject: [PATCH] Clean up after cnos tests (#45564) (cherry picked from commit 0b433b3ea984c460ace15de0f917d0883ea2e649) (cherry picked from commit 71b3951d09aed385be0771d01ba739348451e720) --- test/units/modules/network/cnos/test_cnos_bgp.py | 5 ++--- test/units/modules/network/cnos/test_cnos_ethernet.py | 5 ++--- test/units/modules/network/cnos/test_cnos_portchannel.py | 5 ++--- test/units/modules/network/cnos/test_cnos_vlag.py | 5 ++--- test/units/modules/network/cnos/test_cnos_vlan.py | 5 ++--- 5 files changed, 10 insertions(+), 15 deletions(-) diff --git a/test/units/modules/network/cnos/test_cnos_bgp.py b/test/units/modules/network/cnos/test_cnos_bgp.py index 1cff5e53f0e..7315774b088 100644 --- a/test/units/modules/network/cnos/test_cnos_bgp.py +++ b/test/units/modules/network/cnos/test_cnos_bgp.py @@ -2,6 +2,7 @@ from __future__ import (absolute_import, division, print_function) __metaclass__ = type import json +import os from ansible.compat.tests.mock import patch from ansible.modules.network.cnos import cnos_bgp from units.modules.utils import set_module_args @@ -21,6 +22,7 @@ class TestCnosBgpModule(TestCnosModule): def tearDown(self): super(TestCnosBgpModule, self).tearDown() self.mock_run_cnos_commands.stop() + os.remove('test.log') def load_fixtures(self, commands=None, transport='cli'): self.run_cnos_commands.return_value = [load_fixture('cnos_bgp_config.cfg')] @@ -33,9 +35,6 @@ class TestCnosBgpModule(TestCnosModule): 'bgpArg3': '13', 'bgpArg4': 'address-family', 'bgpArg5': 'ipv4', 'bgpArg6': 'next-hop-self'}) result = self.execute_module(changed=True) - file = open('Anil.txt', "a") - file.write(str(result)) - file.close() expected_result = 'BGP configurations accomplished' self.assertEqual(result['msg'], expected_result) diff --git a/test/units/modules/network/cnos/test_cnos_ethernet.py b/test/units/modules/network/cnos/test_cnos_ethernet.py index 201e8e126bb..f6512737f18 100644 --- a/test/units/modules/network/cnos/test_cnos_ethernet.py +++ b/test/units/modules/network/cnos/test_cnos_ethernet.py @@ -2,6 +2,7 @@ from __future__ import (absolute_import, division, print_function) __metaclass__ = type import json +import os from ansible.compat.tests.mock import patch from ansible.modules.network.cnos import cnos_interface from units.modules.utils import set_module_args @@ -21,6 +22,7 @@ class TestCnosEthernetModule(TestCnosModule): def tearDown(self): super(TestCnosEthernetModule, self).tearDown() self.mock_run_cnos_commands.stop() + os.remove('test.log') def load_fixtures(self, commands=None, transport='cli'): self.run_cnos_commands.return_value = [load_fixture('cnos_ethernet_config.cfg')] @@ -31,9 +33,6 @@ class TestCnosEthernetModule(TestCnosModule): 'outputfile': 'test.log', 'interfaceOption': 'ethernet', 'interfaceRange': '33', 'interfaceArg1': 'channel-group', 'interfaceArg2': '33', 'interfaceArg3': 'on'}) result = self.execute_module(changed=True) - file = open('Anil.txt', "a") - file.write(str(result)) - file.close() expected_result = 'Interface Configuration is Accomplished' self.assertEqual(result['msg'], expected_result) diff --git a/test/units/modules/network/cnos/test_cnos_portchannel.py b/test/units/modules/network/cnos/test_cnos_portchannel.py index e7c76331c22..0e15f28a79b 100644 --- a/test/units/modules/network/cnos/test_cnos_portchannel.py +++ b/test/units/modules/network/cnos/test_cnos_portchannel.py @@ -2,6 +2,7 @@ from __future__ import (absolute_import, division, print_function) __metaclass__ = type import json +import os from ansible.compat.tests.mock import patch from ansible.modules.network.cnos import cnos_portchannel from units.modules.utils import set_module_args @@ -21,6 +22,7 @@ class TestCnosPortchannelModule(TestCnosModule): def tearDown(self): super(TestCnosPortchannelModule, self).tearDown() self.mock_run_cnos_commands.stop() + os.remove('test.log') def load_fixtures(self, commands=None, transport='cli'): self.run_cnos_commands.return_value = [load_fixture('cnos_portchannel_config.cfg')] @@ -31,9 +33,6 @@ class TestCnosPortchannelModule(TestCnosModule): 'outputfile': 'test.log', 'interfaceRange': '33', 'interfaceArg1': 'channel-group', 'interfaceArg2': '33', 'interfaceArg3': 'on'}) result = self.execute_module(changed=True) - file = open('Anil.txt', "a") - file.write(str(result)) - file.close() expected_result = 'Port Channel Configuration is done' self.assertEqual(result['msg'], expected_result) diff --git a/test/units/modules/network/cnos/test_cnos_vlag.py b/test/units/modules/network/cnos/test_cnos_vlag.py index 051cf3c3b12..981281a07cc 100644 --- a/test/units/modules/network/cnos/test_cnos_vlag.py +++ b/test/units/modules/network/cnos/test_cnos_vlag.py @@ -2,6 +2,7 @@ from __future__ import (absolute_import, division, print_function) __metaclass__ = type import json +import os from ansible.compat.tests.mock import patch from ansible.modules.network.cnos import cnos_vlag from units.modules.utils import set_module_args @@ -21,6 +22,7 @@ class TestCnosVlagModule(TestCnosModule): def tearDown(self): super(TestCnosVlagModule, self).tearDown() self.mock_run_cnos_commands.stop() + os.remove('test.log') def load_fixtures(self, commands=None, transport='cli'): self.run_cnos_commands.return_value = [load_fixture('cnos_vlag_config.cfg')] @@ -30,9 +32,6 @@ class TestCnosVlagModule(TestCnosModule): 'host': '10.241.107.39', 'deviceType': 'g8272_cnos', 'outputfile': 'test.log', 'vlagArg1': 'enable'}) result = self.execute_module(changed=True) - file = open('Anil.txt', "a") - file.write(str(result)) - file.close() expected_result = 'VLAG configurations accomplished' self.assertEqual(result['msg'], expected_result) diff --git a/test/units/modules/network/cnos/test_cnos_vlan.py b/test/units/modules/network/cnos/test_cnos_vlan.py index 97318e4fc57..ce41a035734 100644 --- a/test/units/modules/network/cnos/test_cnos_vlan.py +++ b/test/units/modules/network/cnos/test_cnos_vlan.py @@ -2,6 +2,7 @@ from __future__ import (absolute_import, division, print_function) __metaclass__ = type import json +import os from ansible.compat.tests.mock import patch from ansible.modules.network.cnos import cnos_vlan from units.modules.utils import set_module_args @@ -21,6 +22,7 @@ class TestCnosVlanModule(TestCnosModule): def tearDown(self): super(TestCnosVlanModule, self).tearDown() self.mock_run_cnos_commands.stop() + os.remove('test.log') def load_fixtures(self, commands=None, transport='cli'): self.run_cnos_commands.return_value = [load_fixture('cnos_vlan_config.cfg')] @@ -31,9 +33,6 @@ class TestCnosVlanModule(TestCnosModule): 'outputfile': 'test.log', 'vlanArg1': '13', 'vlanArg2': 'name', 'vlanArg3': 'anil'}) result = self.execute_module(changed=True) - file = open('Anil.txt', "a") - file.write(str(result)) - file.close() expected_result = 'VLAN configuration is accomplished' self.assertEqual(result['msg'], expected_result)