An in-memory Shiny session driven from async test code.
Construct one with test_server_async rather than directly. The session runs the app's server function against a mock connection — no browser and no network server — so inputs can be set and outputs asserted in process.
Use it as an async context manager to keep the session alive across several user interactions:
asyncwith test_server_async(server) as session:await session.set_inputs(x=10)assert session.outputs["doubled"] =="20"
async with is the only supported way to run a session: it starts the app on entry and always tears it down on exit, including when the test fails. Values registered with shiny.testmode.export_test_values are read with get_export.
Re-read the session's output, export, and error values.
set_inputs already does this, so an explicit call is only needed after something outside the test changes reactive state (for example an effect driven by a timer).
A TestServerValue, with status"silent" if the output’s latest render produced nothing. It compares equal to the value itself, so session.get_output("txt") == "hi" works.
Return the keys dict(session) produces. See TestServerValues.
make_scope
testserver.AsyncTestServerSession.make_scope(id)
Return a view of this session namespaced to a module instance.
Mirrors shiny.Session.make_scope: inside a module the app's server code uses bare ids, and so does the returned view, while the session underneath keeps the namespaced ones.
Set input values and wait for the resulting reactive flush.
Simulates a user interaction: the values are sent to the session as an input update, and the call returns once the reactive graph has settled and the values read by get_input, get_output, and get_export have been refreshed.
Input values keyed by input id. Ids that are not valid Python identifiers – a module’s namespaced "counter-n", say – go through an unpacked dictionary: set_inputs(**{"counter-n": 7}).