Commit 4582aade authored by Denis Laxalde's avatar Denis Laxalde
Browse files

[test] ensure mocking is stopped in cwctl tests

Either use a decorator or ensure that cleanup is performed.

This is so as to prevent global state modification.
parent 8673da7c2f85
......@@ -107,16 +107,17 @@ class InstanceCommandTest(unittest.TestCase):
# pretend that this instance exists
cwcfg.config_for = MagicMock(return_value=object())
def test_getting_called(self):
_TestCommand.test_instance = MagicMock(return_value=0)
patcher = patch.object(cwcfg, 'config_for', return_value=object())
@patch.object(_TestCommand, 'test_instance', return_value=0)
def test_getting_called(self, test_instance):
try:["test", "some_instance"])
except SystemExit as ex: # CWCTL will finish the program after that
self.assertEqual(ex.code, 0)
@patch.object(cwctl, 'get_pdb')
def test_pdb_not_called(self, get_pdb):
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment