# HG changeset patch # User Denis Laxalde # Date 1563786555 -7200 # Node ID 5e7212209ea6263480d6f19f2c4e221020e90a05 # Parent 8673da7c2f85cac1ef732bdde251c6d9038a31d9 [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. diff -r 8673da7c2f85 -r 5e7212209ea6 cubicweb/test/unittest_cwctl.py --- a/cubicweb/test/unittest_cwctl.py Tue May 21 16:47:13 2019 +0200 +++ b/cubicweb/test/unittest_cwctl.py Mon Jul 22 11:09:15 2019 +0200 @@ -107,16 +107,17 @@ self.CWCTL.register(_TestFailCommand) # pretend that this instance exists - cwcfg.config_for = MagicMock(return_value=object()) + patcher = patch.object(cwcfg, 'config_for', return_value=object()) + patcher.start() + self.addCleanup(patcher.stop) - def test_getting_called(self): - _TestCommand.test_instance = MagicMock(return_value=0) - + @patch.object(_TestCommand, 'test_instance', return_value=0) + def test_getting_called(self, test_instance): try: self.CWCTL.run(["test", "some_instance"]) except SystemExit as ex: # CWCTL will finish the program after that self.assertEqual(ex.code, 0) - _TestCommand.test_instance.assert_called_with("some_instance") + test_instance.assert_called_with("some_instance") @patch.object(cwctl, 'get_pdb') def test_pdb_not_called(self, get_pdb):