Beispiel #1
0
 def test_kill(self, monkeypatch):
     """Test kill ServerProcessError"""
     serv = Server(path='abc')
     serv.proc = Mock()
     monkeypatch.setattr(os, 'kill', Mock(side_effect=OSError))
     with pytest.raises(ServerProcessError):
         serv.kill()
Beispiel #2
0
 def test_kill_fail(self):
     """Test when kill fails"""
     serv = Server(path=PATH)
     serv.proc = 1
     serv.pid = -300
     with pytest.raises(ServerProcessError):
         serv.kill()
Beispiel #3
0
 def test_kill_fail(self):
     """Test when kill fails"""
     serv = Server(path=PATH)
     serv.proc = 1
     serv.pid = -300
     with pytest.raises(ServerProcessError):
         serv.kill()
Beispiel #4
0
 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()
Beispiel #5
0
 def test_kill(self, monkeypatch):
     """Test kill ServerProcessError"""
     serv = Server(path='abc')
     serv.proc = Mock()
     monkeypatch.setattr(os, 'kill', Mock(side_effect=OSError))
     with pytest.raises(ServerProcessError):
         serv.kill()
Beispiel #6
0
 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()
Beispiel #7
0
    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()
Beispiel #8
0
 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
Beispiel #9
0
 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)
Beispiel #10
0
 def test_normal_kill(self, monkeypatch):
     """Test kill when normally called"""
     serv = Server(path='abc')
     serv.proc = Mock()
     monkeypatch.setattr(os, 'kill', Mock())
     res = serv.kill()
     assert res is True
     assert serv.proc is None
Beispiel #11
0
 def test_normal_kill(self, monkeypatch):
     """Test kill when normally called"""
     serv = Server(path='abc')
     serv.proc = Mock()
     monkeypatch.setattr(os, 'kill', Mock())
     res = serv.kill()
     assert res is True
     assert serv.proc is None
Beispiel #12
0
    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()
Beispiel #13
0
 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)
Beispiel #14
0
 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
Beispiel #15
0
    def test_is_not_alive(self, monkeypatch):
        """ Test that is_alive returns True when the
            underlying proc returns None on Poll
        """
        serv = Server()
        serv.proc = Mock()
        monkeypatch.setattr(serv.proc, "poll", Mock(return_value=123))

        assert serv.is_alive() is False
Beispiel #16
0
    def test_is_not_alive(self, monkeypatch):
        """ Test that is_alive returns True when the
            underlying proc returns None on Poll
        """
        serv = Server()
        serv.proc = Mock()
        monkeypatch.setattr(serv.proc, 'poll', Mock(return_value=123))

        assert serv.is_alive() is False
Beispiel #17
0
 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)
Beispiel #18
0
 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)
Beispiel #19
0
    def test_args_are_passed(self, monkeypatch):
        """ Test that wait_for_output passes all
            Arguments to the underlying ProcessMonitor
        """
        serv = Server()
        serv.proc = Mock()
        monkeypatch.setattr(serv.proc, "wait_for_output", Mock())

        serv.wait_for_output("foo", timeout=123, count=456)
        serv.proc.wait_for_output.called_once_with("foo", timeout=123, count=456)
Beispiel #20
0
    def test_error_is_passed(self, monkeypatch):
        """ Test that wait_for_output passes all
            Exceptions from the underlying ProcessMonitor
        """
        serv = Server()
        serv.proc = Mock()
        monkeypatch.setattr(serv.proc, "wait_for_output", Mock(side_effect=MatchTimeoutError))

        with pytest.raises(MatchTimeoutError):
            serv.wait_for_output("foo", timeout=123, count=456)
Beispiel #21
0
    def test_error_is_passed(self, monkeypatch):
        """ Test that wait_for_output passes all
            Exceptions from the underlying ProcessMonitor
        """
        serv = Server()
        serv.proc = Mock()
        monkeypatch.setattr(serv.proc, 'wait_for_output',
                            Mock(side_effect=MatchTimeoutError))

        with pytest.raises(MatchTimeoutError):
            serv.wait_for_output("foo", timeout=123, count=456)
Beispiel #22
0
    def test_args_are_passed(self, monkeypatch):
        """ Test that wait_for_output passes all
            Arguments to the underlying ProcessMonitor
        """
        serv = Server()
        serv.proc = Mock()
        monkeypatch.setattr(serv.proc, 'wait_for_output', Mock())

        serv.wait_for_output("foo", timeout=123, count=456)
        serv.proc.wait_for_output.called_once_with("foo",
                                                   timeout=123,
                                                   count=456)
Beispiel #23
0
    def test_terminate_fail(self):
        """Test when terminate fails"""
        class FakeProc(object):
            """A mock process"""
            def __init__(self):
                pass

            def terminate(self):
                """Terminate the mock process"""
                raise OSError

        serv = Server(path=PATH)
        serv.proc = FakeProc()
        with pytest.raises(ServerProcessError):
            serv.terminate()
Beispiel #24
0
    def test_terminate_fail(self):
        """Test when terminate fails"""
        class FakeProc(object):

            """A mock process"""

            def __init__(self):
                pass

            def terminate(self):
                """Terminate the mock process"""
                raise OSError

        serv = Server(path=PATH)
        serv.proc = FakeProc()
        with pytest.raises(ServerProcessError):
            serv.terminate()
Beispiel #25
0
 def test_normal_terminate(self):
     """Test terminal when normally called"""
     serv = Server(path='abc')
     serv.proc = MockProcess(True)
     serv.terminate()
     assert serv.proc is None
Beispiel #26
0
 def test_normal_terminate(self):
     """Test terminal when normally called"""
     serv = Server(path='abc')
     serv.proc = MockProcess(True)
     serv.terminate()
     assert serv.proc is None
Beispiel #27
0
 def test_terminate(self):
     """Test terminate ServerProcessError"""
     serv = Server(path='abc')
     serv.proc = MockProcess(False)
     with pytest.raises(ServerProcessError):
         serv.terminate()
Beispiel #28
0
 def test_terminate(self):
     """Test terminate ServerProcessError"""
     serv = Server(path='abc')
     serv.proc = MockProcess(False)
     with pytest.raises(ServerProcessError):
         serv.terminate()