def test_gcov_flush_fail(self): """Test when gcov_flush fails""" serv = Server(path=PATH) serv.proc = 1 serv.pid = -300 with pytest.raises(ServerProcessError): serv.gcov_flush()
def test_gov_flush_fail(self): """Test when gov_flush fails""" serv = Server(path=PATH) serv.proc = Mock(ProcessMonitor) serv.proc.send_signal.side_effect = OSError with pytest.raises(ServerProcessError): serv.gcov_flush()
def test_normal_gcov_flush(self, monkeypatch): """Test gcov_flush""" serv = Server(path='abc') serv.proc = Mock() monkeypatch.setattr(os, 'kill', Mock()) res = serv.gcov_flush() assert res is True assert serv.proc is not None
def test_terminate_cov(self): """Test terminate and gcov_flush ServerProcessError""" serv = Server(path='abc') serv.proc = MockProcess(False) serv.gcov_flush = Mock() serv.make_coverage = Mock() with pytest.raises(ServerProcessError): serv.terminate(True)
def test_kill_cov(self, monkeypatch): """Test kill and gcov_flush ServerProcessError""" serv = Server(path='abc') serv.proc = MockProcess(False) serv.gcov_flush = Mock() serv.make_coverage = Mock() monkeypatch.setattr(os, 'kill', Mock(side_effect=OSError)) with pytest.raises(ServerProcessError): serv.kill(True)
def test_no_process_gov_flush(self): """Test when no process exists and gcov_flush is called""" serv = Server(path=PATH) with pytest.raises(ServerProcessError): serv.gcov_flush()