Ejemplo n.º 1
0
 def test_enable_receiving_bound_socket(self, context, socket_path):
     sock = socket.socket(socket.AF_UNIX, socket.SOCK_DGRAM)
     # cause an error by binding the socket, thus testing error handling in
     # this method
     sock.bind(str(socket_path))
     monitor = Monitor.from_socket(context, str(socket_path))
     with pytest.raises(EnvironmentError) as exc_info:
         monitor.enable_receiving()
     pytest.assert_env_error(exc_info.value, errno.EADDRINUSE, str(socket_path))
Ejemplo n.º 2
0
 def test_set_receive_buffer_size_privilege_error(self, monitor):
     with pytest.raises(EnvironmentError) as exc_info:
         monitor.set_receive_buffer_size(1000)
     pytest.assert_env_error(exc_info.value, errno.EPERM)
Ejemplo n.º 3
0
 def test_from_device_file_non_existing(self, context, tmpdir):
     filename = tmpdir.join("test")
     assert not tmpdir.check(file=True)
     with pytest.raises(EnvironmentError) as excinfo:
         Device.from_device_file(context, str(filename))
     pytest.assert_env_error(excinfo.value, errno.ENOENT, str(filename))
Ejemplo n.º 4
0
def test_get_device_type_not_existing(tmpdir):
    filename = tmpdir.join('test')
    assert not tmpdir.check(file=True)
    with pytest.raises(EnvironmentError) as excinfo:
        _util.get_device_type(str(filename))
    pytest.assert_env_error(excinfo.value, errno.ENOENT, str(filename))
Ejemplo n.º 5
0
 def test_from_device_file_non_existing(self, context, tmpdir):
     filename = tmpdir.join('test')
     assert not tmpdir.check(file=True)
     with pytest.raises(EnvironmentError) as excinfo:
         Device.from_device_file(context, str(filename))
     pytest.assert_env_error(excinfo.value, errno.ENOENT, str(filename))
Ejemplo n.º 6
0
 def test_set_receive_buffer_size_privilege_error(self, monitor,
                                                  socket_path):
     with pytest.raises(EnvironmentError) as exc_info:
         monitor.set_receive_buffer_size(1000)
     pytest.assert_env_error(exc_info.value, errno.EPERM)