tests.conftest module¶
Shared pytest fixtures and cross-file test helpers.
- tests.conftest.PROJECT_ROOT = PosixPath('/home/runner/work/repomatic/repomatic')¶
Root of the repository.
- tests.conftest.IN_GIT_CHECKOUT = True¶
Whether the suite runs from a git checkout, not from an sdist or a tag tarball.
A packager’s source carries no git history, holds a release’s frozen workflows, and, for an sdist, a
pyproject.tomlrewritten and symlinks dereferenced by the build backend. The tests markedrepo_maintenancecheck those properties of a development checkout, sopytest_collection_modifyitems()skips them everywhere else.
- tests.conftest.PACKAGE_DIR = PosixPath('/home/runner/work/repomatic/repomatic/repomatic')¶
Root of the package whose sources the conformance tests scan.
- tests.conftest.PACKAGE_FILES = [PosixPath('/home/runner/work/repomatic/repomatic/repomatic/__init__.py'), PosixPath('/home/runner/work/repomatic/repomatic/repomatic/__main__.py'), PosixPath('/home/runner/work/repomatic/repomatic/repomatic/awesome_toc.py'), PosixPath('/home/runner/work/repomatic/repomatic/repomatic/broken_links.py'), PosixPath('/home/runner/work/repomatic/repomatic/repomatic/bundle.py'), PosixPath('/home/runner/work/repomatic/repomatic/repomatic/cache.py'), PosixPath('/home/runner/work/repomatic/repomatic/repomatic/changelog.py'), PosixPath('/home/runner/work/repomatic/repomatic/repomatic/checks.py'), PosixPath('/home/runner/work/repomatic/repomatic/repomatic/claude_plugin.py'), PosixPath('/home/runner/work/repomatic/repomatic/repomatic/cli/__init__.py'), PosixPath('/home/runner/work/repomatic/repomatic/repomatic/cli/ci.py'), PosixPath('/home/runner/work/repomatic/repomatic/repomatic/cli/deps.py'), PosixPath('/home/runner/work/repomatic/repomatic/repomatic/cli/github.py'), PosixPath('/home/runner/work/repomatic/repomatic/repomatic/cli/main.py'), PosixPath('/home/runner/work/repomatic/repomatic/repomatic/cli/release.py'), PosixPath('/home/runner/work/repomatic/repomatic/repomatic/cli/repo.py'), PosixPath('/home/runner/work/repomatic/repomatic/repomatic/cli/site.py'), PosixPath('/home/runner/work/repomatic/repomatic/repomatic/cli/tools.py'), PosixPath('/home/runner/work/repomatic/repomatic/repomatic/cloudflare/__init__.py'), PosixPath('/home/runner/work/repomatic/repomatic/repomatic/cloudflare/api.py'), PosixPath('/home/runner/work/repomatic/repomatic/repomatic/cloudflare/pages.py'), PosixPath('/home/runner/work/repomatic/repomatic/repomatic/cloudflare/r2.py'), PosixPath('/home/runner/work/repomatic/repomatic/repomatic/cloudflare/redirects.py'), PosixPath('/home/runner/work/repomatic/repomatic/repomatic/components.py'), PosixPath('/home/runner/work/repomatic/repomatic/repomatic/config.py'), PosixPath('/home/runner/work/repomatic/repomatic/repomatic/data/__init__.py'), PosixPath('/home/runner/work/repomatic/repomatic/repomatic/data/awesome_template/__init__.py'), PosixPath('/home/runner/work/repomatic/repomatic/repomatic/deps/__init__.py'), PosixPath('/home/runner/work/repomatic/repomatic/repomatic/deps/audit.py'), PosixPath('/home/runner/work/repomatic/repomatic/repomatic/deps/cooldown.py'), PosixPath('/home/runner/work/repomatic/repomatic/repomatic/deps/graph.py'), PosixPath('/home/runner/work/repomatic/repomatic/repomatic/deps/lockfile.py'), PosixPath('/home/runner/work/repomatic/repomatic/repomatic/deps/pins.py'), PosixPath('/home/runner/work/repomatic/repomatic/repomatic/deps/policy.py'), PosixPath('/home/runner/work/repomatic/repomatic/repomatic/deps/provenance.py'), PosixPath('/home/runner/work/repomatic/repomatic/repomatic/deps/report.py'), PosixPath('/home/runner/work/repomatic/repomatic/repomatic/deps/requirements.py'), PosixPath('/home/runner/work/repomatic/repomatic/repomatic/deps/shippable.py'), PosixPath('/home/runner/work/repomatic/repomatic/repomatic/deps/sources.py'), PosixPath('/home/runner/work/repomatic/repomatic/repomatic/deps/sync.py'), PosixPath('/home/runner/work/repomatic/repomatic/repomatic/deps/uv.py'), PosixPath('/home/runner/work/repomatic/repomatic/repomatic/docs.py'), PosixPath('/home/runner/work/repomatic/repomatic/repomatic/file_inventory.py'), PosixPath('/home/runner/work/repomatic/repomatic/repomatic/file_ops.py'), PosixPath('/home/runner/work/repomatic/repomatic/repomatic/frontmatter.py'), PosixPath('/home/runner/work/repomatic/repomatic/repomatic/git_ops.py'), PosixPath('/home/runner/work/repomatic/repomatic/repomatic/github/__init__.py'), PosixPath('/home/runner/work/repomatic/repomatic/repomatic/github/caches.py'), PosixPath('/home/runner/work/repomatic/repomatic/repomatic/github/ci_status.py'), PosixPath('/home/runner/work/repomatic/repomatic/repomatic/github/dev_release.py'), PosixPath('/home/runner/work/repomatic/repomatic/repomatic/github/event.py'), PosixPath('/home/runner/work/repomatic/repomatic/repomatic/github/gh.py'), PosixPath('/home/runner/work/repomatic/repomatic/repomatic/github/issue.py'), PosixPath('/home/runner/work/repomatic/repomatic/repomatic/github/job_timings.py'), PosixPath('/home/runner/work/repomatic/repomatic/repomatic/github/labels.py'), PosixPath('/home/runner/work/repomatic/repomatic/repomatic/github/outputs.py'), PosixPath('/home/runner/work/repomatic/repomatic/repomatic/github/pr.py'), PosixPath('/home/runner/work/repomatic/repomatic/repomatic/github/pr_body.py'), PosixPath('/home/runner/work/repomatic/repomatic/repomatic/github/release_sync.py'), PosixPath('/home/runner/work/repomatic/repomatic/repomatic/github/releases.py'), PosixPath('/home/runner/work/repomatic/repomatic/repomatic/github/runs.py'), PosixPath('/home/runner/work/repomatic/repomatic/repomatic/github/sponsor.py'), PosixPath('/home/runner/work/repomatic/repomatic/repomatic/github/status.py'), PosixPath('/home/runner/work/repomatic/repomatic/repomatic/github/threads.py'), PosixPath('/home/runner/work/repomatic/repomatic/repomatic/github/token.py'), PosixPath('/home/runner/work/repomatic/repomatic/repomatic/github/unsubscribe.py'), PosixPath('/home/runner/work/repomatic/repomatic/repomatic/github/urls.py'), PosixPath('/home/runner/work/repomatic/repomatic/repomatic/github/workflow_files.py'), PosixPath('/home/runner/work/repomatic/repomatic/repomatic/github/workflow_sync.py'), PosixPath('/home/runner/work/repomatic/repomatic/repomatic/gitignore.py'), PosixPath('/home/runner/work/repomatic/repomatic/repomatic/hashing.py'), PosixPath('/home/runner/work/repomatic/repomatic/repomatic/http.py'), PosixPath('/home/runner/work/repomatic/repomatic/repomatic/humanize.py'), PosixPath('/home/runner/work/repomatic/repomatic/repomatic/images.py'), PosixPath('/home/runner/work/repomatic/repomatic/repomatic/init/__init__.py'), PosixPath('/home/runner/work/repomatic/repomatic/repomatic/init/local_edits.py'), PosixPath('/home/runner/work/repomatic/repomatic/repomatic/init/removed_assets.py'), PosixPath('/home/runner/work/repomatic/repomatic/repomatic/init/run.py'), PosixPath('/home/runner/work/repomatic/repomatic/repomatic/init/tool_config.py'), PosixPath('/home/runner/work/repomatic/repomatic/repomatic/init/upgrade.py'), PosixPath('/home/runner/work/repomatic/repomatic/repomatic/lint_changelog.py'), PosixPath('/home/runner/work/repomatic/repomatic/repomatic/lint_repo/__init__.py'), PosixPath('/home/runner/work/repomatic/repomatic/repomatic/lint_repo/context.py'), PosixPath('/home/runner/work/repomatic/repomatic/repomatic/lint_repo/pins.py'), PosixPath('/home/runner/work/repomatic/repomatic/repomatic/lint_repo/repo.py'), PosixPath('/home/runner/work/repomatic/repomatic/repomatic/lint_repo/roster.py'), PosixPath('/home/runner/work/repomatic/repomatic/repomatic/lint_repo/settings.py'), PosixPath('/home/runner/work/repomatic/repomatic/repomatic/lint_repo/site.py'), PosixPath('/home/runner/work/repomatic/repomatic/repomatic/lint_repo/tool_config.py'), PosixPath('/home/runner/work/repomatic/repomatic/repomatic/lint_repo/workflows.py'), PosixPath('/home/runner/work/repomatic/repomatic/repomatic/mailmap.py'), PosixPath('/home/runner/work/repomatic/repomatic/repomatic/markdown.py'), PosixPath('/home/runner/work/repomatic/repomatic/repomatic/matrix/__init__.py'), PosixPath('/home/runner/work/repomatic/repomatic/repomatic/matrix/axes.py'), PosixPath('/home/runner/work/repomatic/repomatic/repomatic/matrix/model.py'), PosixPath('/home/runner/work/repomatic/repomatic/repomatic/matrix/runner_sync.py'), PosixPath('/home/runner/work/repomatic/repomatic/repomatic/matrix/runners.py'), PosixPath('/home/runner/work/repomatic/repomatic/repomatic/metadata/__init__.py'), PosixPath('/home/runner/work/repomatic/repomatic/repomatic/metadata/core.py'), PosixPath('/home/runner/work/repomatic/repomatic/repomatic/metadata/env.py'), PosixPath('/home/runner/work/repomatic/repomatic/repomatic/metadata/git.py'), PosixPath('/home/runner/work/repomatic/repomatic/repomatic/metadata/matrix.py'), PosixPath('/home/runner/work/repomatic/repomatic/repomatic/metadata/output.py'), PosixPath('/home/runner/work/repomatic/repomatic/repomatic/metadata/project.py'), PosixPath('/home/runner/work/repomatic/repomatic/repomatic/metrics/__init__.py'), PosixPath('/home/runner/work/repomatic/repomatic/repomatic/metrics/chart.py'), PosixPath('/home/runner/work/repomatic/repomatic/repomatic/metrics/forge.py'), PosixPath('/home/runner/work/repomatic/repomatic/repomatic/metrics/store.py'), PosixPath('/home/runner/work/repomatic/repomatic/repomatic/npm.py'), PosixPath('/home/runner/work/repomatic/repomatic/repomatic/pypi.py'), PosixPath('/home/runner/work/repomatic/repomatic/repomatic/pyproject.py'), PosixPath('/home/runner/work/repomatic/repomatic/repomatic/release/__init__.py'), PosixPath('/home/runner/work/repomatic/repomatic/repomatic/release/attestation.py'), PosixPath('/home/runner/work/repomatic/repomatic/repomatic/release/binaries_page.py'), PosixPath('/home/runner/work/repomatic/repomatic/repomatic/release/binary.py'), PosixPath('/home/runner/work/repomatic/repomatic/repomatic/release/manpages.py'), PosixPath('/home/runner/work/repomatic/repomatic/repomatic/release/prepare_release.py'), PosixPath('/home/runner/work/repomatic/repomatic/repomatic/release/protocol.py'), PosixPath('/home/runner/work/repomatic/repomatic/repomatic/release/self_pin.py'), PosixPath('/home/runner/work/repomatic/repomatic/repomatic/release/verify.py'), PosixPath('/home/runner/work/repomatic/repomatic/repomatic/release/virustotal.py'), PosixPath('/home/runner/work/repomatic/repomatic/repomatic/setup_guide.py'), PosixPath('/home/runner/work/repomatic/repomatic/repomatic/skills.py'), PosixPath('/home/runner/work/repomatic/repomatic/repomatic/tabular.py'), PosixPath('/home/runner/work/repomatic/repomatic/repomatic/templates/__init__.py'), PosixPath('/home/runner/work/repomatic/repomatic/repomatic/templating.py'), PosixPath('/home/runner/work/repomatic/repomatic/repomatic/tooling/__init__.py'), PosixPath('/home/runner/work/repomatic/repomatic/repomatic/tooling/binaries.py'), PosixPath('/home/runner/work/repomatic/repomatic/repomatic/tooling/checksums.py'), PosixPath('/home/runner/work/repomatic/repomatic/repomatic/tooling/nuitka.py'), PosixPath('/home/runner/work/repomatic/repomatic/repomatic/tooling/registry.py'), PosixPath('/home/runner/work/repomatic/repomatic/repomatic/tooling/runner.py'), PosixPath('/home/runner/work/repomatic/repomatic/repomatic/upstream.py'), PosixPath('/home/runner/work/repomatic/repomatic/repomatic/versions.py')]¶
Every Python module shipped in the package.
Sorted because
@pytest.mark.parametrizederives test IDs from iteration order, andpytest-xdistaborts a run whose workers disagree on them.
- tests.conftest.SITE_ANCHOR_RE = re.compile('https://repomatic\\.net/(?P<page>[\\w-]+)#(?P<anchor>[\\w-]+)')¶
A link into one section of the published documentation.
- tests.conftest.WORKFLOWS_DIR = PosixPath('/home/runner/work/repomatic/repomatic/.github/workflows')¶
Directory holding this repository’s own workflow files.
- tests.conftest.REAL_HTTP_MARKER = 'real_http'¶
Marks a test that runs a registry tool for real, downloads included.
The
_no_real_httpfixture leaves such a test alone, so the probe ofskip_unless_tool_runs()can download the pinned binary on a cold cache.tests/test_suite_hygiene.pyholds every caller of that probe to the marker.
- tests.conftest.docs_heading_slug(title)[source]¶
The anchor the published Sphinx site derives from a heading.
Follows the docutils section-id algorithm (lowercase, every non-alphanumeric run collapsed to one hyphen, trimmed), which is what the published page exposes as
id=attributes.
- tests.conftest.docs_heading_anchors(page)[source]¶
Anchors a page of
docs/exposes: heading slugs and explicit targets.Heading slugs follow
docs_heading_slug().
- tests.conftest.assert_shipped_text_reads_true_downstream(origin, text)[source]¶
Check a text that travels downstream cites nothing a repository lacks.
A bundled configuration and a generated workflow comment both land in repositories that hold no copy of this project’s
AGENTS.md: theagentcomponent that shipped its sections retired in7.14.0. A pointer to that file is a dead end there. So such a text states its rationale inline, or cites a section of the published documentation, whose anchor is held here to a heading that exists.
- tests.conftest.pytest_configure(config)[source]¶
Register the markers local to this suite.
Not in
[tool.pytest] markers, which must match the template bundled inrepomatic/data/pytest.toml.- Return type:
- tests.conftest.pytest_collection_modifyitems(config, items)[source]¶
Skip the
repo_maintenancetests outside a git checkout.See
IN_GIT_CHECKOUT.- Return type:
- tests.conftest.WORKFLOWS_WITH_CONCURRENCY_BLOCK = ('autofix.yaml', 'changelog.yaml', 'debug.yaml', 'docs.yaml', 'labels.yaml', 'lint.yaml', 'metrics.yaml', 'release.yaml', 'self-maintenance.yaml', 'tests.yaml')¶
Workflows that actually define a concurrency block, read off disk.
Derived rather than hand-listed because two test modules assert against it from opposite directions, and a hand-listed pair drifted apart once already: a workflow can be exempt from the requirement and still carry a block, which no list of intentions can express.
- tests.conftest.WORKFLOWS_WITHOUT_CONCURRENCY_BLOCK = ('_release-build.yaml', '_release-engine.yaml', 'autolock.yaml', 'cancel-runs.yaml', 'unsubscribe.yaml')¶
The complement of
WORKFLOWS_WITH_CONCURRENCY_BLOCK.
- tests.conftest.skip_unless_tool_runs(name)[source]¶
Skip the calling test when a registry tool cannot run on this machine.
A test that lints generated output reads the tool’s verdict off its exit code, and a
uvxresolution that fails offline exits non-zero too. Probing with--versionfirst keeps the two apart, so whatever the real invocation returns afterwards is the tool’s opinion of the content rather than a fetch failure misread as a defect in the generator.The probe installs the tool, and a binary tool or companion downloads through
repomatic.httpon a cold cache. The caller carries theREAL_HTTP_MARKERmarker so_no_real_httplets that download through: CI starts from a cold cache, and it is the enforcement point.Only a developer with no network ever takes the skip. A failed download, a platform the tool publishes no binary for, and a missing
uvxall skip.
- tests.conftest.load_workflow(workflow_name)[source]¶
Load and parse one of this repository’s workflow YAML files.
The one loader behind every test that reads a workflow off disk, so they all parse the same bytes the same way.
- tests.conftest.requested_metadata_keys(command, package)[source]¶
Positional keys a shell command passes to the
show-metadatasubcommand.Built on the reader
unknown_metadata_keysruns in production, for the tests that hold the workflows to the keys they request. A call of the removedmetadataalias requests nothing, since the command it names no longer exists.
- tests.conftest.hermetic_git(monkeypatch)[source]¶
Shield temporary git repos from the developer’s own git configuration.
Commit signing, hooks, templates and identity from the global or system config would otherwise leak into repos a test builds under
tmp_pathand break hermeticity in machine-specific ways.
- tests.conftest.scrub_workflow_event(monkeypatch)[source]¶
Detach a test from the CI run’s own workflow event.
In CI the suite inherits the real run’s
GITHUB_EVENT_NAME, event payload andGITHUB_SHA, which event-derived properties (event_type,commit_range, the canary gating ofnuitka_matrix) read, so expectations would differ between CI and a local run. Deleting the event markers pins a test to the deterministic local behavior; a test of the CI context sets the variables back withmonkeypatch.setenv.
- tests.conftest.run_git(*args, cwd)[source]¶
Run a git command in cwd and return its stdout.
- Return type:
- tests.conftest.seed_commit(workdir, filename, content, message)[source]¶
Create a file and commit it with a throwaway identity.
- Return type:
- tests.conftest.SHALLOW_HISTORY = ('apple', 'banana', 'cherry', 'date', 'elderberry')¶
Content of the successive commits
make_shallow_clone()pushes.
- tests.conftest.make_shallow_clone(tmp_path)[source]¶
Clone a remote holding one commit per
SHALLOW_HISTORYentry.The clone is one commit deep. The remote serves any commit it can reach by SHA, as GitHub does, so a commit outside the clone can be fetched alone.
- class tests.conftest.FakeResponse(data, *, status=200, headers=None)[source]¶
Bases:
objectMinimal
urlopenresponse double: a byte body behind a context manager.Stands in for the object
repomatic.http.request()reads, so network tests patchrepomatic.http.urlopenwithreturn_value=FakeResponse(...).
- class tests.conftest.CutShortBody(initial_bytes=b'')[source]¶
Bases:
BytesIOThe body of an error answer whose connection drops mid-read.
- tests.conftest.pat_results(**overrides)[source]¶
Build a
PatPermissionResultswhere every check passes by default.Each keyword names a
PatPermissionResultsfield and replaces its(passed, message)pair, so a test spells out only the checks whose outcome it cares about and the rest read as the happy path.
- tests.conftest.metadata_from_pyproject(tmp_path, monkeypatch, content)[source]¶
Build a
Metadatareading a throwawaypyproject.tomlholding content.Repointing
Metadata.pyproject_pathis what isolates the instance from the repository’s ownpyproject.toml: the class reads that path lazily, so the patch has to be in place before the first property is touched. The autouse_reset_metadatafixture clears the cached values afterwards.
- tests.conftest.cache_env(monkeypatch, tmp_path)[source]¶
Point the repomatic cache at a per-test directory, auto-purge disabled.
Returns the cache root path so tests can assert on its contents.
- tests.conftest.patch_gh(module, **mock_kwargs)[source]¶
Patch a module’s
ghdispatch points with one shared mock.Read paths go through
gh_json(which calls theghmodule’srun_gh_command) while write paths call the name imported into module directly; patching both with the same mock keeps a test’s single call sequence intact across the two layers. Bind the module withfunctools.partialfor a per-file shorthand.
- tests.conftest.attribute_docstrings(body)[source]¶
Yield
(line, owner, text)for each attribute docstring in body.An attribute docstring is the bare string literal following an assignment.
ast.get_docstringcannot see one, yet it is this project’s convention for documenting a dataclass field or a module constant, andautomodule ... :undoc-members:renders it.
- tests.conftest.write_bundle(path, *subjects)[source]¶
Write a sigstore bundle attesting subjects.
Mirrors the shape
actions/attestemits: a DSSE envelope whose base64 payload is an in-toto statement listing one entry per attested file.- Return type:
- tests.conftest.MULTI_RELEASE_CHANGELOG = '# Changelog\n\n## [2.0.0 (unreleased)](https://github.com/user/repo/compare/v1.1.0...main)\n\n> [!WARNING]\n> This version is **not released yet** and is under active development.\n\n## [1.1.0 (2026-02-10)](https://github.com/user/repo/compare/v1.0.0...v1.1.0)\n\n- Second release.\n\n## [1.0.0 (2025-12-01)](https://github.com/user/repo/compare/v0.9.0...v1.0.0)\n\n- Initial release.\n'¶
Changelog with multiple released versions and one unreleased.
- tests.conftest.SHT_STRTAB = 3¶
ELF section type of a string table.
- tests.conftest.make_elf(machine, versions=(), *, wide=True, big_endian=False, extended_numbering=False)[source]¶
Craft a minimal ELF file, requiring versions of libc when given.
Without versions the file holds a bare header and no section table. With them it carries a
.dynstrstring table and a.gnu.version_rsection naming each one under a singlelibc.so.6requirement, the way the linker writes them. wide picks ELF64 over ELF32, and big_endian the byte order, as the identification bytes declare them. extended_numbering moves the section count out ofe_shnuminto thesh_sizeof entry0, the encoding a file with0xff00sections or more has to use.- Return type:
- tests.conftest.pack_macho_version(version)[source]¶
Pack a
major.minorstring into a Mach-O version integer.- Return type:
- tests.conftest.make_macho(cpu_type, min_os='11.0')[source]¶
Craft a minimal 64-bit Mach-O header with one LC_BUILD_VERSION command.
- Return type:
- tests.conftest.make_fat(slices)[source]¶
Wrap Mach-O slices into a universal (fat) container.
- Return type:
- tests.conftest.make_pe(machine)[source]¶
Craft a minimal PE header exposing only the COFF machine type.
- Return type:
- tests.conftest.macho_cpu_type(arch)[source]¶
The Mach-O
cputypefor an architecture, read for the byte builders.MACHINE_IDSspans every format. These two accessors name the format for the helpers below, which write real header bytes.- Return type: