Liking cljdoc? Tell your friends :D
Clojure only.

com.blockether.vis.internal.foundation.shim-pytest

Built-in sandbox SHIM: a pytest-compatible module for the model's Python sandbox, implemented PURELY in Python on the stdlib (ast, inspect, linecache, traceback, warnings, tempfile) — NO host/JVM bridge, NOT a line of Clojure or babashka. pytest is a third-party wheel that does not ship in GraalPy, so agents writing full Python extensions and wanting to TEST them inline would otherwise hit ModuleNotFoundError; this extension contributes a :ext/sandbox-shims entry that env-python/build-agent-context installs into every sandbox Context (main + every sub_loop fork).

It is NOT real pytest: there is no pluggy/plugin system, no ini/plugin CLI (only -k / -x / --maxfail / -v), and no import-time assertion rewrite. It DOES do conftest.py fixture discovery (walked from the test file's dir up to the fs root, outer→inner) in disk mode. Instead it implements the subset that matters in an inline sandbox where the model writes tests + pytest.main() in ONE block:

  • collection of test_* functions and Test* classes (scoped to the CURRENT block via __vis_src__, so leftovers from earlier blocks in the shared globals are NOT swept in),
  • RUNTIME assert introspection (assert 2 == 3 reconstructed with operand values) done by registering __vis_src__ into linecache and walking the failing frame's AST — the same UX as pytest's rewrite, via a different mechanism,
  • pytest.raises / warns / approx / fail / skip / xfail / importorskip, @pytest.fixture (function/module/session scope, yield-teardown, autouse, recursive injection, parametrized fixtures via params/ids with request.param, request.getfixturevalue chains), @pytest.mark.parametrize (incl. indirect=) / skip / skipif / xfail / usefixtures (+ arbitrary marks), pytest.param, builtin fixtures request / monkeypatch / capsys / capfd / tmp_path / tmp_path_factory / tmpdir / tmpdir_factory / caplog / recwarn / pytester / testdir, conftest.py fixture discovery, and a pytest.main() runner (with -k keyword selection, -x / --maxfail fail-fast, and -v) that prints progress + failure reports
    • a summary line (incl. deselected counts) and returns an exit code.

Unlike shim-yaml/shim-matplotlib there are NO :shim/bindings: the shim is a self-contained Python preamble with zero host callables. It publishes a pytest module into sys.modules (so import pytest works) and staples it onto builtins (so pytest.raises(...) works with NO import, like json/os/requests).

Built-in sandbox SHIM: a `pytest`-compatible module for the model's Python
sandbox, implemented PURELY in Python on the stdlib (`ast`, `inspect`,
`linecache`, `traceback`, `warnings`, `tempfile`) — NO host/JVM bridge, NOT a
line of Clojure or babashka. `pytest` is a third-party wheel that does not
ship in GraalPy, so agents writing full Python extensions and wanting to
TEST them inline would otherwise hit ModuleNotFoundError; this extension
contributes a `:ext/sandbox-shims` entry that
`env-python/build-agent-context` installs into every sandbox Context (main +
every `sub_loop` fork).

It is NOT real pytest: there is no pluggy/plugin system, no ini/plugin CLI
(only `-k` / `-x` / `--maxfail` / `-v`), and no import-time assertion
rewrite. It DOES do `conftest.py` fixture discovery
(walked from the test file's dir up to the fs root, outer→inner) in disk
mode. Instead it
implements the subset that matters in an inline sandbox where the model
writes tests + `pytest.main()` in ONE block:

  - collection of `test_*` functions and `Test*` classes (scoped to the
    CURRENT block via `__vis_src__`, so leftovers from earlier blocks in the
    shared globals are NOT swept in),
  - RUNTIME assert introspection (`assert 2 == 3` reconstructed with operand
    values) done by registering `__vis_src__` into `linecache` and walking
    the failing frame's AST — the same UX as pytest's rewrite, via a
    different mechanism,
  - `pytest.raises` / `warns` / `approx` / `fail` / `skip` / `xfail` /
    `importorskip`, `@pytest.fixture` (function/module/session scope,
    yield-teardown, autouse, recursive injection, parametrized fixtures via
    `params`/`ids` with `request.param`, `request.getfixturevalue` chains),
    `@pytest.mark.parametrize` (incl. `indirect=`) / `skip` / `skipif` / `xfail`
    / `usefixtures` (+ arbitrary marks), `pytest.param`,
    builtin fixtures `request` / `monkeypatch` / `capsys` / `capfd` /
    `tmp_path` / `tmp_path_factory` / `tmpdir` / `tmpdir_factory` /
    `caplog` / `recwarn` / `pytester` / `testdir`, `conftest.py` fixture discovery,
    and a `pytest.main()` runner (with `-k` keyword selection, `-x` /
    `--maxfail` fail-fast, and `-v`) that prints progress + failure reports
    + a summary line (incl. deselected counts) and returns an exit code.

Unlike `shim-yaml`/`shim-matplotlib` there are NO `:shim/bindings`: the shim
is a self-contained Python preamble with zero host callables. It publishes a
`pytest` module into `sys.modules` (so `import pytest` works) and staples it
onto builtins (so `pytest.raises(...)` works with NO import, like
json/os/requests).
raw docstring

vis-extensionclj

source

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close