Skip to content

livery.workshop.testing._import_probe

livery.workshop.testing._import_probe

Import one module and print what its import registered, as JSON.

The conformance kit runs python -m livery.workshop.testing._import_probe <module> in a process of its own, so the module is imported for the first time. The workshop's own registering modules are imported before the recording starts, so a builtin they register is never counted. Then each of their registration functions records its calls, and footman's task tree is captured, for the one import.

Functions:

Name Description
registered_by

What importing module registers, one line per registration.

main

Print what importing the module the first argument names registers.

Attributes:

Name Type Description
REGISTRARS dict[str, tuple[str, ...]]

REGISTRARS module-attribute

REGISTRARS: dict[str, tuple[str, ...]] = {'livery.workshop._categories': ('register_channels',), 'livery.workshop._steps': ('register_step',), 'livery.workshop._points': ('contribute_job',)}

registered_by

registered_by(module: str) -> list[str]

What importing module registers, one line per registration.

Source code in packages/workshop/src/livery/workshop/testing/_import_probe.py
def registered_by(module: str) -> list[str]:
    """What importing *module* registers, one line per registration."""
    from livery.footman import capture

    found: list[str] = []
    for name, functions in REGISTRARS.items():
        owner = importlib.import_module(name)
        for function in functions:
            setattr(owner, function, _recording(getattr(owner, function), found))
    with capture() as captured:
        importlib.import_module(module)
    found += [f"the footman group {name!r}" for name in sorted(captured.groups)]
    found += [f"the footman task {name!r}" for name in sorted(captured.tasks)]
    return found

main

main() -> None

Print what importing the module the first argument names registers.

Source code in packages/workshop/src/livery/workshop/testing/_import_probe.py
def main() -> None:
    """Print what importing the module the first argument names registers."""
    print(json.dumps(registered_by(sys.argv[1])))