Test support, providing the ability to run the event loop from tests.
- class traits_futures.qt.event_loop_helper.AttributeSetter(*args: Any, **kwargs: Any)[source]¶
Simple QObject that allows us to set object attributes from with a running event loop.
- class traits_futures.qt.event_loop_helper.EventLoopHelper[source]¶
Support for running the Qt event loop in unit tests.
- run_until(object, trait, condition, timeout)[source]¶
Run event loop until the given condition holds true, or until timeout.
The condition is re-evaluated, with the object as argument, every time the trait changes.
traits.has_traits.HasTraits) – Object whose trait we monitor.
str) – Name of the trait to monitor for changes.
condition – Single-argument callable, returning a boolean. This will be called with object as the only input.
float) – Number of seconds to allow before timing out with an exception.
RuntimeError – If timeout is reached, regardless of whether the condition is true or not at that point.
- setattr_soon(obj, name, value)[source]¶
Arrange for an attribute to be set once the event loop is running.
In typical usage, obj will be a
HasTraitsinstance and name will be the name of a trait on obj.
This method is not thread-safe. It’s designed to be called from the main thread.