redsun.testing¶
Pytest fixtures for testing components, sessions and services.
A suite loads them with -p redsun.testing, in addopts or on the command
line. Loading them makes every test keep session settings, session logs,
acquisition data and catalogs under its tmp_path, and drop the psygnal
emissions it left queued.
The module defines no qapp, so it combines with pytest-qt.
BuildSession
¶
StartService
¶
build
¶
Return a function building a session, shut down when the test ends.
It takes a session class, made with the configuration given and laid over
what the class declares, or a session already made. Sessions are shut
down in reverse order; one the test shut down itself runs nothing again.
A shutdown that raises does not stop the others: once every session has
been shut down, the fixture raises that error, or an ExceptionGroup of
all of them when more than one session raised.
log_directory
¶
Write session log files under tmp_path, closing any the test left open.
data_directory
¶
Put the default root of acquisition files and catalogs under tmp_path.
config_home
¶
Keep saved session settings in a config folder under tmp_path.
empty_emission_queue
¶
Drop every psygnal emission the test left queued for another thread.
Left queued, an emission is delivered by the next test running the event loop, to whatever its target has become; a destroyed widget ends the interpreter.
start_service
¶
Return a function starting a declared service, stopped when the test ends.
Once the services have stopped, their transports are released and the EPICS address lists they added themselves to are restored, as when a session ends.