--- url: https://testshed.kloudkit.com/guide/getting-started.md description: >- Install TestShed, point it at your image and write a pytest test against a live Docker container. --- # Getting Started TestShed is a pytest plugin that hands your tests real services: a running Docker container, or a Playwright browser, as a fixture. It gets the image, waits for the container to be ready, and removes everything when the test ends. ## At a Glance * A running Docker daemon *(local, or reachable through `DOCKER_HOST`)*. * Python 3.11 or later, and pytest 9 or later. * A pytest config file *(`pyproject.toml`, `pytest.ini`, …)*: TestShed resolves its paths from its directory. ## Install TestShed ::: code-group ```sh [pip] pip install testshed ``` ```sh [uv] uv add testshed --group dev ``` ::: ## Enable It TestShed stays dormant until you pass `--shed`, so it never touches Docker in projects that don't use it. Turn it on, with your image, in your pytest config: ```toml # pyproject.toml [tool.pytest.ini_options] addopts = "--shed --shed-image=ghcr.io/acme/app --shed-tag=tests" ``` ## Write a Test Ask for the `shed` fixture and you get a running container of that image: ```python # tests/test_smoke.py def test_container_is_alive(shed): assert shed.execute(["echo", "hello"]) == "hello" ``` ```sh pytest ``` When the session starts, TestShed makes sure the image exists *(pulling or building it)* and creates a Docker network for the session. The pytest header shows which image and network it used: ```text shed-image: ghcr.io/acme/app:tests shed-network: testshed-app-4821 ``` ## Next Steps * [Images](./images): where the image comes from, and when it's built. * [Containers](./containers): shared and dedicated containers, markers and defaults. * [Inside a Container](./inside-a-container): run commands, read files and inspect processes. --- --- url: https://testshed.kloudkit.com/guide/images.md description: >- How TestShed gets the image your tests run against: tags and digests, and the pull, build, require and rebuild policies. --- # Images Every `shed` container runs one image, set once for the whole session. TestShed gets it before the first test, pulling or building it as the image policy says. ## At a Glance * `--shed-image` is required, without a tag *(`ghcr.io/acme/app`, not `ghcr.io/acme/app:1.2`)*. * `--shed-tag` sets the tag, and defaults to `tests`. ## Tags and Digests `--shed-tag` takes a tag or a digest. A value with a `:` *(`sha256:…`)* is used as a digest, so the image can't change under you: ```sh pytest --shed --shed-image=ghcr.io/acme/app --shed-tag=pr-563 pytest --shed --shed-image=ghcr.io/acme/app --shed-tag=sha256:9f86d0… ``` `--shed-image` can't carry a tag or digest itself, but a registry with a port *(`localhost:5000/app`)* works. The `shed_tag` fixture holds the result *(`ghcr.io/acme/app:pr-563`, or `ghcr.io/acme/app@sha256:…`)*, for tests that start their own containers from the same image. ## Image Policies `--shed-image-policy` decides how the image is acquired: * **`pull`:** use the local image if it exists; otherwise pull it, and build it if the pull fails *(default)*. * **`build`:** build only if the image doesn't exist locally. * **`require`:** use the local image, and stop the session if it doesn't exist. * **`rebuild`:** always build. Use `rebuild` while you change the image, and `require` in CI after a separate build step. ## Building Builds run `docker build` with `--pull`, so base images are always fresh, and tag the result as the shed image: ```sh pytest --shed --shed-image=my-test-image --shed-image-policy=rebuild ``` The build context is the directory of your pytest config, and the Dockerfile is `Dockerfile` in it. Change either: ```sh pytest --shed --shed-image=my-test-image --shed-image-policy=build \ --shed-build-context=docker --shed-dockerfile=Dockerfile.tests ``` `--shed-build-context` is relative to the current directory, and `--shed-dockerfile` to the build context. ## Skipping Docker `--shed-skip-bootstrap` skips the image and the network, for a run of tests that don't start containers *(a unit test subset, say)*. TestShed's fixtures are still registered, but containers can't start without the network. `--collect-only`, `--help`, `--fixtures` and `--markers` skip the image and the network on their own, since they run no tests. ## Next Steps * [Containers](./containers): run the image in your tests. * [Command-Line Options](../reference/options): every flag and its default. --- --- url: https://testshed.kloudkit.com/guide/containers.md description: >- Get a shared or dedicated container per test, configure it with markers and defaults, start it on demand, or attach one that's already running. --- # Containers The `shed` fixture gives a test a running container of the shed image. Tests that don't change anything share one container; markers give a test its own. ## At a Glance * TestShed enabled with `--shed` and an image *(see [Getting Started](./getting-started))*. * Markers are imported from `kloudkit.testshed.docker.decorators`. ## Shared and Dedicated Containers By default, `shed` returns one container shared by the whole session *(`shed_default`)*, so it starts once and tests stay fast. A test with any TestShed marker gets its own container instead, removed when the test ends. Use `@shed_mutable()` for a test that changes the container *(writes files, installs packages)* but needs no other setting: ```python from kloudkit.testshed.docker.decorators import shed_mutable @shed_mutable() def test_install_package(shed): shed.execute("apt-get install -y curl") assert "curl" in shed.execute("which curl") ``` ## Configure With Markers | Marker | Effect | | ------------------------- | -------------------------------------------------------------------------- | | `@shed_env(**envs)` | Set environment variables. | | `@shed_volumes(*mounts)` | Mount files: `(source, dest)` tuples or volume objects. | | `@shed_config(**kwargs)` | Pass any other argument to the container *(`publish`, `command`, `probe`, …)*. | | `@shed_mutable()` | Give the test its own container, without other settings. | ```python from kloudkit.testshed.docker.decorators import shed_config, shed_env @shed_config(publish=[(8080, 80)]) @shed_env(MY_ENV_VAR="hello") def test_configured_app(shed): assert shed.execute("echo $MY_ENV_VAR") == "hello" ``` `@shed_config` arguments go to the container's `run` call, so anything `docker run` takes works there *(`publish`, `command`, `entrypoint`, `user`, `networks`, …)*. Markers work on a class or a module too *(`pytestmark`)*. The one closest to the test wins: a marker on a test replaces the same marker on its class. Each marker applies once per test, so two `@shed_env` on one test keep only one. ### Volumes Every mount is read-only. A relative source resolves against the stubs directory *(`tests/stubs`, or `--shed-stubs-dir`)*: ```python from kloudkit.testshed.docker import InlineVolume, RemoteVolume from kloudkit.testshed.docker.decorators import shed_volumes @shed_volumes( ("nginx.conf", "/etc/nginx/nginx.conf"), InlineVolume("/app/config.txt", "any content you want", mode=0o644), RemoteVolume("/app/config.json", "https://api.example.com/config.json"), ) def test_with_files(shed): ... ``` * **`InlineVolume(path, content, mode=0o644)`:** mounts a file with the given text or bytes. * **`RemoteVolume(path, url, mode=0o644)`:** downloads the URL before the container starts, and mounts the result. It also takes `method`, `allow_redirects`, `raise_for_status` and `request_options` *(passed to `requests`)*. ## Suite-Wide Defaults Override `shed_container_defaults` in your `conftest.py` to set what every `shed` container starts with: ```python import pytest from kloudkit.testshed.docker import Container, HttpProbe class AppContainer(Container): DEFAULT_USER = "app" @pytest.fixture(scope="session") def shed_container_defaults(): return { "container_class": AppContainer, "probe": HttpProbe(port=3000, endpoint="/health"), } ``` Markers are applied on top of the defaults, key by key. `envs` and `volumes` are the exception: a dedicated container takes them from its markers alone, so default `envs` and `volumes` reach only the shared container. `container_class` picks the class every container is wrapped in *(see [Inside a Container](./inside-a-container#custom-container-classes))*. ## Start on Demand With `shed_deferred` `shed_deferred` is a function that starts the container when you call it, for setup that has to happen first, or for several containers in one test: ```python from kloudkit.testshed.docker.decorators import shed_env @shed_env(APP_PORT="3000") def test_deferred(shed_deferred): # Nothing is running yet. container = shed_deferred(envs={"DEBUG": "true"}) assert container.execute("echo $DEBUG") == "true" assert container.execute("echo $APP_PORT") == "3000" def test_replicas(shed_deferred): primary = shed_deferred(envs={"ROLE": "primary"}) replica = shed_deferred(envs={"ROLE": "replica"}) ``` Call arguments merge with the markers: * **`envs`:** merged, call values win. * **`volumes`:** added after the marker's volumes. * **Anything else:** replaces the `@shed_config` value of the same name. ## Attach a Running Container `shed_attach` brings in a container you started yourself, such as a database from a compose file: ```python def test_against_running_db(shed, shed_attach): db = shed_attach("my-postgres") assert db.execute("pg_isready") assert shed.execute(["getent", "hosts", db.name]) ``` The container joins the session's network for the test, so `shed` containers reach it by name, and leaves it when the test ends. TestShed never stops or removes it. It must already be running, and can't be used with `--shed-skip-bootstrap`. ## Other Images With `docker_sidecar` `docker_sidecar` starts a container from any image, on the session's network: ```python def test_with_nginx(docker_sidecar): nginx = docker_sidecar("nginx:latest", publish=[(8080, 80)]) assert nginx.ip() ``` It takes the same arguments as `@shed_config`, and ignores `shed_container_defaults`. The container is removed when the test ends; `docker_module_sidecar` and `docker_session_sidecar` keep it for the module or the session. With `detach=False`, the container runs to completion and the call returns its output. ## Next Steps * [Inside a Container](./inside-a-container): what you can do with the container you get. * [Readiness Probes](./readiness-probes): wait until it's ready. * [Fixtures and Markers](../reference/fixtures): every fixture and its scope. --- --- url: https://testshed.kloudkit.com/guide/inside-a-container.md description: >- Run commands, read files and inspect processes inside a TestShed container, and customize the container class. --- # Inside a Container Every container TestShed gives you, from `shed`, `docker_sidecar` or `shed_attach`, has the same helpers: `execute` runs commands, `fs` reads files and `proc` inspects processes. ## At a Glance * A container from any TestShed fixture. * The image needs the tools the helpers call: a shell, `test`, `ls`, `stat`, `tr`, `cat` and `tail`. ## Run Commands With `execute` `execute` runs a command through the container's shell *(`/bin/sh -c`)* and returns its output, without the trailing newline: ```python def test_commands(shed): assert shed.execute("echo hello") == "hello" assert shed.execute(["echo", "hello"]) == "hello" # A specific shell. shed.execute.bash("set -o pipefail; cat /etc/os-release | head -1") shed.execute.sh(["echo", "portable"]) shed.execute.zsh("print -r -- $ZSH_VERSION") # Another user. assert shed.execute("whoami", user="nobody") == "nobody" ``` A list is joined with spaces, unquoted, before it reaches the shell. `login_shell=True` runs it in a login shell, and other keyword arguments *(`envs`, `workdir`, …)* go to python-on-whales' `execute`. ### When a Command Fails A command that exits non-zero fails the test with the command's error output, without a Python traceback. Pass `raises=True` to get a `DockerException` instead, to assert on it or recover: ```python import pytest from kloudkit.testshed.docker import DockerException def test_missing_file(shed): with pytest.raises(DockerException): shed.execute("cat /nope", raises=True) ``` With `--shed-container-logs`, the container's logs are printed when a command fails the test. ### Check the Exit Code Pass `check=False` to get a `Result` instead of failing the test. It works the same with `execute.bash`, `execute.sh` and `execute.zsh`: ```python def test_exit_code(shed): result = shed.execute("grep -q nope /etc/hostname", check=False) assert result.exit_code == 1 assert not result.ok result = shed.execute.bash("echo out; echo warn >&2", check=False) assert result.stdout == "out" assert result.stderr == "warn" ``` `Result` holds `exit_code`, `ok`, `stdout` and `stderr`, each stream without its trailing newline, and keeps `stderr` when the command succeeds too. With `check=False`, only `user`, `workdir` and `envs` are passed on, and a missing container still fails the test. ## Read Files With `fs` ```python def test_files(shed): assert shed.fs.exists("/etc/hostname") assert "hostname" in shed.fs.ls("/etc") # hidden=True includes dotfiles assert "root" in shed.fs("/etc/passwd") # same as shed.fs.text(...) raw = shed.fs.bytes("/etc/hostname") config = shed.fs.json("/app/config.json") manifest = shed.fs.yaml("/app/manifest.yaml") project = shed.fs.toml("/app/pyproject.toml") assert shed.fs.mode("/etc/hostname") == "644" assert shed.fs.owner("/etc/hostname") == "root" assert shed.fs.group("/etc/hostname") == "root" assert shed.fs.writable("/tmp") assert not shed.fs.writable("/etc/passwd", user="nobody") ``` Files are copied out of the container, so reading works even when the path isn't readable by the container's default user. `writable` asks as the command's user, or the `user=` you pass. ## Inspect Processes With `proc` ```python def test_processes(shed): assert shed.proc.running("nginx") assert shed.proc.pids("nginx") # tuple of matching PIDs assert "nginx" in shed.proc.cmdline("nginx") # command line of the first match assert shed.proc.pids("sleep infinity", full=True) # match the command line assert shed.proc.environ()["PATH"] # environment of PID 1 ``` Names match the process name exactly. The kernel cuts process names at 15 characters, so look up a long name by its first 15. `full=True` on `pids`, `running` and `cmdline` matches the command line instead, its arguments joined with spaces, as `pgrep -f` does. PIDs come lowest first. `cmdline` raises `LookupError` when nothing matches, and `environ` takes another PID. ## The Container Itself * **`ip()`:** the container's address on the session's network. * **`whoami()`:** the user commands run as. * **`env()` / `env(name)`:** the environment commands see, as a dict, or one value *(`None` when unset)*. Unlike `proc.environ()`, which reads PID 1, it includes what the shell's profile or activation exports. * **`wrapped`:** the underlying python-on-whales container, with its exact type. * **`name`, `id`, `logs()`, …:** anything else is passed to the underlying [python-on-whales](https://gabrieldemarmiesse.github.io/python-on-whales/) container. ## Custom Container Classes Subclass `Container` to change how commands run, and set it as `container_class` *(per call, or in `shed_container_defaults`)*: ```python from kloudkit.testshed.docker import Container class AppContainer(Container): DEFAULT_USER = "app" # user= for every command DEFAULT_SHELL = "/bin/bash" # shell for execute(...) LOGIN_SHELL = True # run commands in a login shell ZSH_PATH = "/bin/zsh" # where execute.zsh finds zsh ``` `BASH_PATH` *(`/bin/bash`)*, `SH_PATH` *(`/bin/sh`)* and `ZSH_PATH` *(`/usr/bin/zsh`)* are the shells `execute.bash`, `execute.sh` and `execute.zsh` use. ## Next Steps * [Readiness Probes](./readiness-probes): make sure the container is ready before you use it. * [Containers](./containers#suite-wide-defaults): set a container class for the whole suite. --- --- url: https://testshed.kloudkit.com/guide/readiness-probes.md description: >- Wait until a TestShed container is ready with HTTP, log and shell probes, set suite-wide defaults and adjust timeouts. --- # Readiness Probes A probe holds a test back until its container is ready, so the test doesn't race the container's startup. If the container isn't ready in time, the test fails with what the probe waited for. ## At a Glance * Probes are imported from `kloudkit.testshed.docker`. * Probes run inside the container: `HttpProbe` needs `curl` in the image, or another command. ## Built-In Probes ```python from kloudkit.testshed.docker import HttpProbe, LogProbe, ShellProbe # An HTTP endpoint answers. HttpProbe(port=3000, endpoint="/health", timeout=30.0) # A regex matches the container's output. LogProbe(pattern=r"ready to accept connections", timeout=30.0) # A command exits 0. ShellProbe(command="pg_isready -U postgres", timeout=30.0) ``` * **`HttpProbe`:** runs `curl http://localhost:` inside the container. Any HTTP status counts; use `command="curl -f"` to require a success status. Set `command` to use another client *(`command="wget -qO-"`)*, or `host` for another address *(with its scheme, `http://localhost` by default)*. * **`LogProbe`:** searches the container's logs for `pattern`. * **`ShellProbe`:** runs `command` *(a string or a list)* through the container's shell, like `execute`. Each probe retries every 100 ms, for up to `timeout` seconds *(30 by default)*. An attempt that hangs runs past `timeout`, so bound a command that can hang *(`curl -m 5`)*. ## Use a Probe Pass a probe wherever a container starts: ```python from kloudkit.testshed.docker import HttpProbe, ShellProbe from kloudkit.testshed.docker.decorators import shed_config @shed_config(probe=HttpProbe(port=8080, endpoint="/healthz")) def test_app(shed): ... def test_db(docker_sidecar): docker_sidecar( "postgres:16", envs={"POSTGRES_PASSWORD": "x"}, probe=ShellProbe(command="pg_isready -U postgres"), ) ``` For every `shed` container, set `probe` in `shed_container_defaults` *(see [Containers](./containers#suite-wide-defaults))*. ## Override the Default Probe A probe passed to a test combines with the default one: * **Same type:** the fields you set replace the default's. Fields you leave out keep the default's value when they default to nothing *(`port`, `endpoint`)*; `timeout`, `host` and `command` come from the new probe either way. `HttpProbe(endpoint="/ready")` keeps the default's port, with a 30-second timeout. * **Another type:** it replaces the default. * **`probe=None`:** no probe for this container. To wait longer without restating the probe, pass only `timeout`: ```python @shed_config(timeout=90.0) def test_slow_boot(shed): ... ``` ## Wait Mid-Test `wait()` runs the container's own probe again, with the same retries, timeout and early failure when the container exits. `probe=` and `timeout=` override it as in `@shed_config`: ```python from kloudkit.testshed.docker import LogProbe, ShellProbe def test_restart(shed): shed.execute("service app restart") shed.wait() # the probe it started with shed.wait(timeout=90) # own probe, longer shed.execute("app reindex &") shed.wait(probe=ShellProbe(command="test -e /tmp/indexed"), timeout=60) shed.wait(probe=LogProbe(pattern=r"reindex done")) ``` They combine with the container's probe exactly as they do at startup *(see [Override the Default Probe](#override-the-default-probe))*. A container started without a probe *(or attached with `shed_attach`)* needs one passed in. ## Write Your Own Subclass `Probe` with a `check` that raises until the container is ready, and a `failure_message` for the timeout: ```python from dataclasses import dataclass from kloudkit.testshed.docker import Probe @dataclass(slots=True) class FileProbe(Probe): path: str = "/tmp/ready" def check(self, container): if not container.fs.exists(self.path): raise FileNotFoundError(self.path) @property def failure_message(self): return f"{self.path} did not appear within {self.timeout}s" ``` Run commands in `check` with `raises=True`: without it, the first failed attempt fails the test instead of retrying. ## When a Probe Times Out The test fails with what the probe waited for and the error of its last attempt: ```text URL [http://localhost:3000/health] was not reachable within 30.0s Last attempt: /bin/sh: 1: curl: not found ``` Run with `--shed-container-logs` to see the container's logs as well. If the container exits before the probe passes, the test fails at once instead of waiting out the timeout, with the exit code and the last 20 lines of the container's logs: ```text Container exited with code 1 before it was ready: URL [http://localhost:3000/health] was not reachable within 30.0s --- last 20 lines of its logs --- Error: listen EADDRINUSE: address already in use :::3000 ``` ## Next Steps * [Containers](./containers#suite-wide-defaults): set a default probe for the whole suite. * [Cleanup and Parallel Runs](./cleanup): container logs on failure. --- --- url: https://testshed.kloudkit.com/guide/playwright-browsers.md description: >- Drive a Chromium browser that runs in a Playwright container, with no browser installed on the host. --- # Playwright Browsers `playwright_browser` gives your tests a Chromium browser that runs in a container, on the session's network. Nothing but the Playwright Python package is needed on the host. ## At a Glance * TestShed enabled with `--shed`. * Docker can pull `mcr.microsoft.com/playwright`, and the container can reach the npm registry *(it starts the server with `npx playwright run-server`)*. ## Drive the Browser ```python def test_example_website(playwright_browser): page = playwright_browser.new_page() page.goto("https://example.com") assert "Example Domain" in page.title() ``` The fixture is session-scoped: every test shares one browser. Open a page or context per test to keep them apart. ## Reach Your Containers The browser runs on the session's network, so it reaches `shed` containers by address: ```python def test_app_page(shed, playwright_browser): page = playwright_browser.new_page() page.goto(f"http://{shed.ip()}:3000") ``` ## Use the Clipboard Pages and contexts the browser opens get the `clipboard-read` and `clipboard-write` permissions, so tests can copy and paste. Permissions you pass to `new_page` or `new_context` are added to them: ```python def test_paste(playwright_browser): page = playwright_browser.new_page(permissions=["geolocation"]) ``` The page needs a secure origin *(`https`, or `localhost`)* for `navigator.clipboard` to exist. `playwright_browser.wrapped` is the plain Playwright `Browser`, without the extra permissions. ## Which Image The container runs `mcr.microsoft.com/playwright` at the same version as the `playwright` package you have installed, so the client and the browser always match. Upgrade the package and the image follows. ## Next Steps * [Containers](./containers): start the services the browser tests. * [Fixtures and Markers](../reference/fixtures): every fixture TestShed registers. --- --- url: https://testshed.kloudkit.com/guide/cleanup.md description: >- How TestShed removes containers, volumes and networks, runs in parallel with pytest-xdist, and shows container logs on failure. --- # Cleanup and Parallel Runs TestShed removes what it starts, when the fixture that started it goes out of scope, and again at the end of the session. Each session gets its own network and labels, so parallel runs don't collide. ## At a Glance * Nothing to set up: cleanup and xdist support are always on. * `--shed-container-logs` prints container logs when a test fails. ## What Gets Removed * **Containers:** removed with their anonymous volumes when their fixture ends: after the test for `shed` with markers, `docker_sidecar` and `shed_deferred`; after the module or the session for the wider-scoped fixtures. * **Volume files:** the temporary files behind `InlineVolume` and `RemoteVolume`. * **The network:** removed at the end of the session. At the end of the session, TestShed also removes any container still carrying the session's label, so a test that crashed mid-setup doesn't leave one behind. Containers you attach with `shed_attach` are never removed. Every container carries two labels, for finding them while a session runs: | Label | Value | | ----------------------------- | -------------------------------------------------- | | `com.kloudkit.testshed` | The session, such as `testshed-app-1f3a9c2e`. | | `com.kloudkit.testshed.test` | The test that started a `shed` container *(its pytest node ID, or `shed_default`)*. | ```sh docker ps -a --filter label=com.kloudkit.testshed ``` Pressing `Ctrl-C` stops the session and still runs the cleanup; it can take a moment. ## Parallel Runs `pytest -n auto` *(pytest-xdist)* works without extra setup: ```sh pytest -n auto ``` The network name and labels include the xdist worker *(`gw0`, `gw1`, …)*, so workers don't share containers, and each worker cleans up its own. ## Container Logs on Failure `--shed-container-logs` prints a container's logs when a test fails because of it: a command that failed, or a probe that timed out. ```sh pytest --shed-container-logs ``` ## Next Steps * [Command-Line Options](../reference/options): every flag and its default. * [Readiness Probes](./readiness-probes): fail fast when a container isn't ready. --- --- url: https://testshed.kloudkit.com/guide/agent-skill.md description: >- Install the TestShed Agent Skill so Claude Code, Codex, Cursor and other coding agents write TestShed tests the way this guide does. --- # Agent Skill The TestShed skill teaches a coding agent how to write, fix and review tests with TestShed. It follows the open Agent Skills format, so any agent that reads skills picks it up. ## At a Glance * A coding agent that reads Agent Skills *(Claude Code, Codex, Cursor, OpenCode, Gemini CLI and others)*. * `npx skills` needs Node.js 22.20 or later. ## Install the Skill ::: code-group ```sh [skills CLI] npx skills add kloudkit/testshed ``` ```text [Claude Code] /plugin marketplace add kloudkit/testshed /plugin install testshed@testshed ``` ::: `npx skills add` asks which agents to install it for; `-a claude-code` picks one and `-g` installs it for every project. To install by hand, copy [`skills/testshed`](https://github.com/kloudkit/testshed/tree/main/skills/testshed) into the directory your agent loads skills from. ## What the Agent Learns The agent loads the skill when a task touches TestShed: a pytest config with `--shed`, a test using `shed` or a sidecar, or a request to add container tests to a project. It then: * **Reads the setup first:** your `addopts`, `conftest.py` defaults and wrapper fixtures, and the stubs directory. * **Picks the fixture:** the shared `shed` for checks, a marker when the test changes the container, `shed_deferred` and sidecars for dependencies. * **Waits with probes:** no `sleep`, and a `LogProbe` before asserting on a later log line. * **Avoids the traps:** default `envs` dropped by markers, read-only mounts, unquoted list commands, `detach=False` raising instead of failing. * **Runs what it writes:** and says so when Docker isn't reachable, instead of reporting a pass. The skill's detail pages load only when the agent needs them, so it stays cheap to keep installed. ## Without the Skill Point the agent at the docs instead. [`llms.txt`](https://testshed.kloudkit.com/llms.txt) lists every page with a link to its raw Markdown, and [`llms-full.txt`](https://testshed.kloudkit.com/llms-full.txt) holds them all in one file. ## Next Steps * [Containers](./containers): the fixtures and markers the skill chooses between. * [Readiness Probes](./readiness-probes): how the agent waits for a container. * [Fixtures and Markers](../reference/fixtures): everything the skill can reach for. --- --- url: https://testshed.kloudkit.com/reference/fixtures.md description: >- Every fixture and marker TestShed registers, with its scope and what it returns. --- # Fixtures and Markers TestShed registers these fixtures and markers whenever `--shed` is set, with no import or `conftest.py` needed. Markers are imported from `kloudkit.testshed.docker.decorators` when you apply them. ## Containers | Fixture | Scope | Returns | | ------------------------ | -------- | ----------------------------------------------------------------------------- | | `shed` | function | The shared container, or a dedicated one when the test has markers. | | `shed_deferred` | function | `shed_deferred(envs=…, volumes=…, **kwargs)`: starts a container when called. | | `shed_attach` | function | `shed_attach(name_or_id)`: wraps a running container you manage. | | `shed_default` | session | The shared container `shed` returns without markers. | | `shed_factory` | function | Starts a shed container with the defaults merged in; behind `shed`. | | `docker_sidecar` | function | `docker_sidecar(image, **kwargs)`: starts a container from any image. | | `docker_module_sidecar` | module | Same as `docker_sidecar`, removed after the module. | | `docker_session_sidecar` | session | Same as `docker_sidecar`, removed after the session. | | `playwright_browser` | session | A Playwright `Browser` connected to Chromium in a container, with clipboard permissions. | ## Settings and Paths | Fixture | Scope | Returns | | ------------------------- | -------- | --------------------------------------------------------------------------- | | `shed_container_defaults` | session | `{}`; override it to set defaults for every `shed` container. | | `shed_tag` | session | The image used, as `image:tag` or `image@sha256:…`. | | `shed_state` | session | The session's resolved settings: image, tag, network, labels and paths. | | `test_root` | session | The tests directory, as an absolute path *(`--shed-tests-dir`)*. | | `project_root` | session | The source directory, as an absolute path *(`--shed-src-dir`)*. | | `downloader` | function | `downloader(url, output)`: downloads into `tmp_path`, returns the `Path`. | `downloader` also takes `method`, `allow_redirects`, `raise_for_status` and `request_options` *(passed to `requests`)*. ## Container Arguments `docker_sidecar`, `shed_deferred` and `@shed_config` take any argument of python-on-whales' `docker.run`, plus: | Argument | Description | | ----------------- | -------------------------------------------------------------------------- | | `probe` | A readiness probe to wait for; `None` for none. | | `timeout` | Seconds to wait for the probe, keeping its other fields. | | `container_class` | The `Container` subclass to wrap the container in. | | `volumes` | `(source, dest)` tuples or volume objects, mounted read-only. | | `networks` | Networks to join instead of the session's network. | | `detach` | `False` runs the container to completion and returns its output *(sidecars only)*. | ## Markers | Marker | Effect | | ------------------------ | ----------------------------------------------------------------- | | `@shed_env(**envs)` | Set environment variables. | | `@shed_volumes(*mounts)` | Mount `(source, dest)` tuples or volume objects, read-only. | | `@shed_config(**kwargs)` | Pass container arguments *(see above)*. | | `@shed_mutable()` | Give the test its own container, without other settings. | --- --- url: https://testshed.kloudkit.com/reference/options.md description: Every TestShed command-line option, with its default. --- # Command-Line Options Every option TestShed adds to pytest. Paths are relative to the directory of your pytest config file, except `--shed-build-context`, which is relative to the current directory. | Option | Default | Description | | ---------------------------- | --------------------------------------- | ------------------------------------------------------------------- | | `--shed` | off | Enable TestShed for the current test suite. | | `--shed-image IMAGE` | none, required | Image repository, without a tag *(e.g. `ghcr.io/acme/app`)*. | | `--shed-tag TAG\|SHA` | `tests` | Image tag, or a digest *(`sha256:…`)*. | | `--shed-image-policy POLICY` | `pull` | `pull`, `build`, `require` or `rebuild` *(see [Images](../guide/images#image-policies))*. | | `--shed-build-context DIR` | the pytest config's directory | Build context for `build`, `rebuild` and the `pull` fallback. | | `--shed-dockerfile FILE` | `Dockerfile` | Dockerfile, relative to the build context. | | `--shed-src-dir DIR` | `src` | Source directory, for `project_root`. | | `--shed-tests-dir DIR` | `tests` | Tests directory, for `test_root`. | | `--shed-stubs-dir DIR` | `tests/stubs` | Where relative `@shed_volumes` sources resolve. | | `--shed-skip-bootstrap` | off | Skip the image and network, for tests that start no containers. | | `--shed-container-logs` | off | Print container logs when a command or probe fails a test. |