null
null
¶
Null backend for .protocol.ContainerRuntime.
Runs no subprocesses — useful for tests and dry-run modes. Every handle
operation returns a safe default (None, False, [], empty
strings). NullRuntime.exec returns an empty success.
State fixtures can be injected via NullRuntime.set_container_state
and NullRuntime.add_image when tests need a specific shape.
ExecStdioStep = tuple[str, bytes]
module-attribute
¶
NullLogStream
¶
NullPortReservation(host='127.0.0.1')
¶
NullContainer(name, *, runtime)
¶
Container handle that reads from a NullRuntime's fixtures.
Source code in src/terok_sandbox/runtime/null.py
name = name
instance-attribute
¶
state
property
¶
Return the fixture state, or None when unset.
running
property
¶
Return True when the fixture state is "running".
started_at
property
¶
Return the fixture start timestamp, or None when unset.
image
property
¶
Return the fixture image, or None when unset.
rw_size
property
¶
Return the fixture rw_size, or None when unset.
id
property
¶
Return the fixture container ID, or None when unset.
mounts
property
¶
Return the fixture mounts, or [] when unset.
env
property
¶
Fixture environment recorded for this container; {} when unset.
__repr__()
¶
__eq__(other)
¶
__hash__()
¶
start()
¶
stop(*, timeout=10)
¶
wait(timeout=None)
¶
copy_in(src, dest)
¶
login_command(*, command=())
¶
logs(*, follow=False, tail=None)
¶
Return an empty NullLogStream.
stream_initial_logs(ready_check, timeout_sec)
¶
Return the fixture readiness result (default True).
NullImage(ref, *, runtime)
¶
Image handle backed by NullRuntime fixtures.
Source code in src/terok_sandbox/runtime/null.py
ref = ref
instance-attribute
¶
id
property
¶
Return the ref itself when the image exists, else None.
repository
property
¶
Return the fixture repository, or "".
tag
property
¶
Return the fixture tag, or "".
size
property
¶
Return the fixture size, or "".
created
property
¶
Return the fixture created timestamp, or "".
__repr__()
¶
__eq__(other)
¶
__hash__()
¶
exists()
¶
labels()
¶
history()
¶
remove()
¶
Remove from the fixture; return True when actually removed.
Source code in src/terok_sandbox/runtime/null.py
NullRuntime()
¶
Stub ContainerRuntime for tests and dry-run modes.
All state lives in dictionaries on the runtime instance. Tests
pre-populate fixtures via the set_container_state,
add_image, etc. helpers.
Source code in src/terok_sandbox/runtime/null.py
set_container_state(name, state)
¶
set_container_started_at(name, timestamp)
¶
set_container_image(name, image_ref)
¶
set_container_rw_size(name, bytes_)
¶
set_container_id(name, container_id)
¶
Record the full container ID Container.id returns for name.
set_container_env(name, env)
¶
set_container_mounts(name, mounts)
¶
Record the (source, destination) mounts for container name.
set_exit_code(name, code)
¶
Record the exit code Container.wait will return for name.
set_ready_result(name, ready)
¶
Record the outcome Container.stream_initial_logs returns.
add_image(ref, *, repository='', tag='', size='', created='', labels=None, history=())
¶
Register an image fixture.
Source code in src/terok_sandbox/runtime/null.py
set_exec_result(container_name, cmd, result)
¶
Pre-register the result exec returns for exact cmd.
Source code in src/terok_sandbox/runtime/null.py
set_exec_stdio_script(container_name, cmd, script, *, exit_code=0)
¶
Pre-register a stdio interaction for exec_stdio.
script is a sequence of ("read", bytes) / ("write", bytes)
steps replayed in order: read consumes the matching prefix from
the caller-supplied stdin; write emits the bytes to stdout.
Use this to drive deterministic ACP-handshake tests without spinning
up a real container.
Source code in src/terok_sandbox/runtime/null.py
container(name)
¶
Return a NullContainer handle.
containers_with_prefix(prefix)
¶
Return fixtures whose name starts with prefix-.
Source code in src/terok_sandbox/runtime/null.py
image(ref)
¶
images(*, dangling_only=False)
¶
Return fixture images; dangling_only filters by tag == "<none>".
Source code in src/terok_sandbox/runtime/null.py
exec(container, cmd, *, timeout=None)
¶
Return a pre-registered result, or a default empty success.
Source code in src/terok_sandbox/runtime/null.py
exec_stdio(container, cmd, *, stdin, stdout, stderr=None, env=None, timeout=None)
¶
Replay a pre-registered stdio script, or no-op with exit code 0.
Records every call (with env) for test inspection. When a script is
registered for (container, cmd), replays it in order: read
consumes from stdin and asserts a match; write pushes bytes to
stdout. Without a script, returns immediately with exit code 0
— matches the empty-success default of exec.
Source code in src/terok_sandbox/runtime/null.py
force_remove(containers)
¶
Record the call and clear every fixture for each container.
Source code in src/terok_sandbox/runtime/null.py
reserve_port(host='127.0.0.1')
¶
Reserve a real host port (even null backend callers want a live port).