Ejemplo n.º 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()
Ejemplo n.º 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()
Ejemplo n.º 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()
Ejemplo n.º 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()
Ejemplo n.º 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()
Ejemplo n.º 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()
Ejemplo n.º 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()
Ejemplo n.º 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
Ejemplo n.º 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)
Ejemplo n.º 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
Ejemplo n.º 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
Ejemplo n.º 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()
Ejemplo n.º 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)
Ejemplo n.º 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
Ejemplo n.º 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
Ejemplo n.º 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
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 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()
Ejemplo n.º 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()
Ejemplo n.º 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
Ejemplo n.º 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
Ejemplo n.º 27
0
 def test_terminate(self):
     """Test terminate ServerProcessError"""
     serv = Server(path='abc')
     serv.proc = MockProcess(False)
     with pytest.raises(ServerProcessError):
         serv.terminate()
Ejemplo n.º 28
0
 def test_terminate(self):
     """Test terminate ServerProcessError"""
     serv = Server(path='abc')
     serv.proc = MockProcess(False)
     with pytest.raises(ServerProcessError):
         serv.terminate()