class labscript_utils.testing_utils.Any(types=<class 'object'>)[source]

A class whose instances equal any object of the given type or tuple of types. For use with mock.Mock.assert_called_with when you don’t care what some of the arguments are

class labscript_utils.testing_utils.ThreadTestCase(*args, **kwargs)[source]

Test case that runs tests in a new thread whilst providing a mainloop that allows running scripts in the current thread. Those scripts can then be tested from the testing thread.

_run(*args, **kwargs)[source]

Called in a thread to run the tests

run(*args, **kwargs)[source]
static wait_for(condition_func, timeout=5, initial_poll_interval=0.005, max_poll_interval=0.5)[source]

Busy wait for a condition to be true. Uses exponential backoff so it’s fast when things are fast and not a complete hog when they’re not

class labscript_utils.testing_utils.dotdict[source]

dot.notation access to dictionary attributes

class labscript_utils.testing_utils.monkeypatch(obj, name, mocked_attr)[source]

Context manager to temporarily monkeypatch an object attribute with some mocked attribute