def teardown(self): """ Stop the collector and terminate VNF & TG instance :return """ try: try: self.collector.stop() for vnf in self.vnfs: LOG.info("Stopping %s", vnf.name) vnf.terminate() LOG.debug("all VNFs terminated: %s", ", ".join(vnf.name for vnf in self.vnfs)) finally: terminate_children() except Exception: # catch any exception in teardown and convert to simple exception # never pass exceptions back to multiprocessing, because some exceptions can # be unpicklable # https://bugs.python.org/issue9400 LOG.exception("") raise RuntimeError("Error in teardown")
def test_no_children(self, mock_multiprocessing): mock_multiprocessing.active_children.return_value = [] process.terminate_children()
def test_some_children(self, mock_multiprocessing): p1 = mock.MagicMock() p2 = mock.MagicMock() mock_multiprocessing.active_children.return_value = [p1, p2] process.terminate_children()