def test_close_dispatch_event(self, mocker): def foo(h: SimulatorHandler): self.__called = True self.__called = False s = SimulatorHandler() s.start("p", "w") s.subscribe(SimulatorEvent.SIMULATION_ENDS, foo) s.close() assert self.__called
def test_close_not_running_must_not_raise(self): s = SimulatorHandler() try: s.close() except: raise pytest.fail("Close raised an exception.") # type: ignore
def test_close_call_network_close(self, mocker): s = SimulatorHandler() mocker.patch("batsim_py.protocol.NetworkHandler.close") s.start("p", "w") s.close() protocol.NetworkHandler.close.assert_called_once()
def test_close_valid(self): s = SimulatorHandler() s.start("p", "w") s.close() assert not s.is_running