API Internals#

class pytest_bluezenv.Call.Proxy#

Upper-tester handle returned as host.call. Calling it (host.call(...)) invokes a function on the VM host. See Call.

__call__(func, *a, **kw)#

Invoke func on the VM.

Parameters:
  • func (callable) – function to run on the VM.

  • *a – positional arguments to func.

  • **kw – keyword arguments to func; sync=False returns a ResultProxy instead of blocking.

Returns:

the function result, or a ResultProxy when sync=False.

Return type:

object

class pytest_bluezenv.Call.ResultProxy(plugin, id_value)#

Handle for a sync=False Call; wait() collects the result once the VM-side call has finished.

wait()#

Wait for and return the result of the asynchronous call.

Returns:

return value of the VM-host function.

Return type:

object

Raises:

RemoteError – the VM-host function raised. It is raised here, when the result is collected, not at call time.

class pytest_bluezenv.Pexpect.Proxy#

Upper-tester handle returned as host.pexpect. spawn() starts a process and returns a CtlProxy.

spawn(cmd)#

Spawn a process on the VM; see spawn.

Parameters:

cmd (sequence) – command and arguments.

Returns:

handle to the spawned process.

Return type:

Pexpect.CtlProxy

class pytest_bluezenv.Pexpect.CtlProxy(plugin, ctl_id)#

Handle for one process spawned by Pexpect.

Attribute access dispatches over RPC, giving send, expect, expect_all and close. Usable as a context manager (closes on exit). The return values match the VM-side plugin methods. expect() gives an (index, groups) tuple, see expect. expect_all() gives a list of matched groups per pattern, see expect_all. Both take a reject sequence of patterns aborting the wait. send() gives the number of bytes sent, see send. close() returns nothing.

class pytest_bluezenv.rpc.Connection(stream, timeout, name=None)[source]#

Bidirectional message queue on a stream, pickle-based

call(method, *a, **kw)[source]#

Make RPC method call.

Invokes a corresponding method of the implementation, usually Implementation.

Parameters:
  • method (str) – Method name

  • *a – Arguments passed to method

  • **kw – Keyword arguments passed to method.

  • timeout (float | None) – keyword argument, call timeout if different from default

Returns:

return value of the method call

Return type:

object

Raises:
call_noreply(method, *a, **kw)[source]#

Make RPC method call with no reply.

Invokes a corresponding method of the implementation, usually Implementation.

Parameters:
  • method (str) – Method name

  • *a – Arguments passed to method

  • **kw – Keyword arguments passed to method.

  • timeout (float | None) – keyword argument, call timeout if different from default

close()[source]#

Close connection synchronously, via close_start + close_finish.

close_finish(force=False)[source]#

Complete asynchronous connection close to complete

Parameters:

force (bool) – Close connection immediately without waiting

close_start()[source]#

Start graceful connection close.

class pytest_bluezenv.env.Implementation[source]#

VM-side main instance: setup/teardown plugins, plugin RPC server side

call_plugin(name, method, *a, **kw)[source]#

Call a plugin method

Parameters:
  • name (str) – plugin name

  • method (str) – method name

  • *a – call arguments

  • **kw – call keyword arguments

Returns:

plugin method call return value

Return type:

object

set_instance_name(name)[source]#

Set name for this tester instance

start_load(plugin)[source]#

Start loading a plugin

Parameters:

plugin (HostPlugin) – plugin to load

teardown()[source]#

Unload all plugins

wait_load()[source]#

Wait until all plugins are loaded.

Returns:

Mapping {name: plugin.value}

Return type:

dict