Commit 33c81a62 authored by Jérome Perrin's avatar Jérome Perrin

tests: fix mock cleanup

`stop` method was not called on the mock controller, it was called on
the mock object and therefore was a no-op.
Also rewrite a bit to just use addCleanup instead of a tearDown method,
for readability (so that cleanup code appears next to the code which
needs cleanup later).
parent 36ea23a8
...@@ -333,16 +333,14 @@ class TestCliConsole(unittest.TestCase): ...@@ -333,16 +333,14 @@ class TestCliConsole(unittest.TestCase):
request_patch = patch.object(slapos.slap.OpenOrder, 'request', return_value = cp) request_patch = patch.object(slapos.slap.OpenOrder, 'request', return_value = cp)
self.mock_request = request_patch.start() self.mock_request = request_patch.start()
self.addCleanup(request_patch.stop)
self.config_file = tempfile.NamedTemporaryFile() self.config_file = tempfile.NamedTemporaryFile()
self.config_file.write('''[slapos] self.config_file.write('''[slapos]
master_url=null master_url=null
''') ''')
self.config_file.flush() self.config_file.flush()
self.addCleanup(self.config_file.close)
def tearDown(self):
self.mock_request.stop()
self.config_file.close()
def test_console_interactive(self): def test_console_interactive(self):
app = slapos.cli.entry.SlapOSApp() app = slapos.cli.entry.SlapOSApp()
......
Markdown is supported
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