tests.test_tool_runner module¶
Tests for the unified tool runner.
- tests.test_tool_runner.test_tool_spec_integrity(name, spec)[source]¶
Each registry entry passes structural integrity checks.
- tests.test_tool_runner.test_bundled_actionlint_labels_name_runners_the_matrix_emits()[source]¶
Every declared label answers a runner the generated workflows can name.
actionlint validates
runs-on:against a list baked into its binary, and rejects a GitHub-hosted label its release predates. The bundled config declares those throughself-hosted-runner, actionlint’s escape hatch for an unrecognized label, which is why the entries carry no implication of being self-hosted.Pinning them to the matrix constants is what keeps the file from rotting: an entry surviving a move to a newer image would go on whitelisting a runner nothing uses, and read as still load-bearing.
- tests.test_tool_runner.test_tool_backend_labels_unique()[source]¶
Every backend resolves distinct display labels for the docs tables.
- tests.test_tool_runner.test_tool_backend_matches_payload_fields(name, spec)[source]¶
Each registry entry maps onto exactly one delivery backend.
- tests.test_tool_runner.test_build_install_args_cooldown(name, spec, tmp_path, monkeypatch)[source]¶
uvx tools carry
--exclude-newer; needs_venv tools only when unlocked.
- tests.test_tool_runner.test_uv_exemptions_follow_the_install_command(name, spec, locked, tmp_path, monkeypatch)[source]¶
A PyPI tool reads
[tool.uv]exemptions exactly whenuvxdoes not install it.lint-repoasksToolBackend.reads_uv_exemptionswhether a project entry can admit a pin inside the window.uvxreads no project configuration, whileuv runanduv pip installread it, so the answer must follow the command the runner builds.
- tests.test_tool_runner.test_uvx_tool_pins_registry_version(name, spec, tmp_path, monkeypatch)[source]¶
Every uvx-installed tool pins its
TOOL_REGISTRYversion in the command.Locks the invariant that keeps the per-tool command tests drift-proof: a version bump in
TOOL_REGISTRYmust flow into thename==versionpin with no hand-edited literal. A hard-codedname==X.Y.Zin an individual test silently goes stale on the next bump (a missedpyproject-fmtliteral once reddened every Tests cell), so version-pinning is asserted here once, generically, against the shared builder rather than restated per tool.The pin sits in the command that installs the tool. With a
uv.lock, a tool declaringinstall_into_venvis installed by its own command.
- tests.test_tool_runner.test_build_install_args_install_into_venv(name, spec, tmp_path, monkeypatch)[source]¶
A tool installed into the project venv runs from it, with no layer.
- tests.test_tool_runner.test_install_into_venv_installs_the_pin(mock_run, name, spec)[source]¶
The pinned tool goes into the venv that
uv run --frozenreports.
- tests.test_tool_runner.test_install_into_venv_reports_a_uv_failure(mock_run, results, message)[source]¶
A uv failure stops the run before the tool starts.
- tests.test_tool_runner.test_datasource_url_by_backend()[source]¶
datasource_url points at npmjs for npm tools, GitHub/PyPI otherwise.
- tests.test_tool_runner.test_install_npm_command_shape(mock_which, mock_run, tmp_path)[source]¶
The npm on PATH installs the pinned npm, which installs the tool.
Both installs land in a prefix of their own, block install scripts and carry the cooldown.
- tests.test_tool_runner.test_install_npm_rejects_an_unverified_signature(mock_which, mock_run, tmp_path)[source]¶
A failed signature audit fails the install, after the tool landed.
- tests.test_tool_runner.test_install_npm_zero_cooldown_omits_flag(mock_which, mock_run, tmp_path)[source]¶
A 0-day cooldown drops the min-release-age flag from both installs.
- tests.test_tool_runner.test_install_npm_without_npm_raises(mock_which, tmp_path)[source]¶
A clear error surfaces when Node.js and npm are not on PATH.
- tests.test_tool_runner.test_install_npm_stops_at_a_failed_install(mock_which, mock_run, tmp_path, returncode, message)[source]¶
A failed bootstrap install stops before the tool install and the audit.
- tests.test_tool_runner.test_npm_supports_cooldown(mock_run, version_output, supported)[source]¶
min-release-age support is gated on npm >= 11.10.0.
- tests.test_tool_runner.test_install_npm_warns_when_npm_too_old(mock_which, mock_run, tmp_path, caplog)[source]¶
An npm that cannot enforce the cooldown warns, but still installs.
Running the pinned npm itself installs it with the npm on PATH, which is then the one the floor check reads.
- tests.test_tool_runner.test_pinned_npm_enforces_the_cooldown()[source]¶
The npm that installs every npm-backed tool honors
min-release-age.A pin moved below the floor would install every tool with the cooldown ignored, and the bootstrap would hide it.
- tests.test_tool_runner.test_run_tool_npm_runs_the_installed_executable(mock_ci, mock_install_npm, mock_run, tmp_path, monkeypatch)[source]¶
An npm tool runs from its scratch prefix, installed with the cooldown in days.
- tests.test_tool_runner.test_problem_matcher_reads_the_output_of_its_tool(spec)[source]¶
A bundled matcher is a valid matcher file, keyed on a named owner.
actionlint’s own line format, with and without the color codes of its
-colorflag, is what the pattern has to read.
- tests.test_tool_runner.test_run_tool_wraps_the_run_in_its_problem_matcher(mock_install_binary, mock_run, tmp_path, monkeypatch, in_ci)[source]¶
In GitHub Actions, the matcher is on for the length of the run, and only then.
The runner reads the matcher file when it processes the registration, so the file lands in the job’s temporary directory, which outlives the process.
- tests.test_tool_runner.test_actionlint_lints_run_scripts_with_the_pinned_shellcheck()[source]¶
actionlint finds shellcheck on PATH, so the registry puts its own there.
- tests.test_tool_runner.test_lookup_tool_rejects_an_unknown_name()[source]¶
One lookup, one error, naming the tools that do exist.
- tests.test_tool_runner.test_resolve_binary_fills_in_the_platform_download()[source]¶
A resolved binary carries what one platform’s download needs.
- tests.test_tool_runner.test_resolve_binary_refuses_a_tool_without_binary()[source]¶
Only a binary tool has a download to resolve.
- tests.test_tool_runner.test_release_source_refuses_a_download_off_github_releases(url)[source]¶
Only a GitHub release asset names the release that serves it.
- tests.test_tool_runner.test_with_overrides_pins_another_version_and_checksum()[source]¶
The overrides reach the download URL and the checksum on record.
- tests.test_tool_runner.test_output_paths_reads_both_flag_forms(args, expected)[source]¶
The report destination is read off either form of the output flag.
- tests.test_tool_runner.test_with_package_pins_keep_the_spelling_of_each_entry()[source]¶
A plugin pin splits into the package name as written and its version.
- tests.test_tool_runner.test_tool_docs_name_the_table_each_tool_reads()[source]¶
bump-my-version is documented under the table it reads.
- tests.test_tool_runner.test_release_badge_follows_the_install_source(name, spec)[source]¶
The release badge reads the registry each tool is installed from.
- tests.test_tool_runner.test_tool_registry_sorted_alphabetically()[source]¶
Registry keys are sorted alphabetically.
- tests.test_tool_runner.test_pypi_name_strips_install_extra()[source]¶
pypi_nameyields the bare PyPI project name, dropping any install extra.Nuitka pins
package="nuitka[onefile]"for installation, but the PyPI JSON API 404s on the bracketed name, sopypi_namemust returnnuitkaforsync-tool-versionsto find the real project.
- tests.test_tool_runner.test_pypi_pin_names_the_package_and_its_version(package, pin)[source]¶
pypi_pinis the exact requirement an installer takes, extra included.The command tests above read the pin from this property, so its shape is stated here once.
- tests.test_tool_runner.test_checksum_sidecar_covers_exactly_binary_tools()[source]¶
CHECKSUMSandVERSIONSare keyed by exactly the binary tool names.
- tests.test_tool_runner.test_checksum_version_matches_registry(name)[source]¶
Each tool’s sidecar version stamp matches its
ToolSpec.version.The offline tripwire: a version bump that did not refresh the checksums leaves
VERSIONSstale, failing here before the release is cut. Fix by runningrepomatic update-checksums.
- tests.test_tool_runner.test_resolve_platform_exact_match()[source]¶
Exact Platform match takes priority over Group membership.
- tests.test_tool_runner.test_resolve_platform_group_match()[source]¶
Group membership matches when no exact Platform key exists.
- tests.test_tool_runner.test_resolve_platform_no_match()[source]¶
No matching key raises RuntimeError.
- tests.test_tool_runner.test_resolve_platform_unknown_distro_falls_back_to_linux()[source]¶
An unidentified distribution still reaches the family-wide
LINUXkey.extra-platforms returns
UNKNOWN_PLATFORMfor any distribution it has yet to learn, and that sentinel belongs to no group, so the group pass misses. The manylinux_2_28 build container (AlmaLinux) is the motivating case: it broke everyrepomatic runbinary on a distro identity that never entered the choice of binary.
- tests.test_tool_runner.test_resolve_platform_unknown_distro_refuses_beyond_linux(urls, sys_platform)[source]¶
The fallback widens to the Linux family and no further.
- tests.test_tool_runner.test_linux_binaries_are_keyed_on_the_family_group()[source]¶
Every tool shipping a Linux binary keys it on the
LINUXgroup.The pass-3 fallback only rescues a family-wide key, so a tool keyed on a specific distribution instead would still fail inside the manylinux build container.
- tests.test_tool_runner.test_platform_cache_key()[source]¶
Cache key is a filesystem-safe string derived from the PlatformKey.
- tests.test_tool_runner.test_get_archive_format_dict_resolution()[source]¶
Dict archive_format resolves Platform > Group membership.
- tests.test_tool_runner.test_get_archive_format_exact_key_resolution()[source]¶
An exact platform key wins, a bare Platform matches every architecture.
A platform neither one names has no format, which raises instead of guessing.
- tests.test_tool_runner.test_tarfile_mode_refuses_a_format_that_is_no_tar(archive_format)[source]¶
Only a tar archive has a
tarfile.openmode.
- tests.test_tool_runner.test_path_tools_env_skips_platform_without_binary(caplog)[source]¶
A companion publishing no binary here is skipped, not fatal.
shfmtships nothing for Windows ARM64, so provisioning it for mdformat can never succeed there. Aborting would makerepomatic run mdformatunusable on the platform rather than merely leaving its shell blocks unformatted, so the run carries on withPATHuntouched.
- tests.test_tool_runner.test_path_tools_env_stops_at_a_companion_that_fails_to_install(mock_install_binary)[source]¶
A companion that fails for another reason than the platform stops the run.
The error names the companion and the tool it serves, which the bare install error does not.
- tests.test_tool_runner.test_run_tool_binary_uses_direct_path(mock_ci, mock_install_binary, mock_run, tmp_path, monkeypatch)[source]¶
Binary tools use the downloaded binary path, not uvx.
- tests.test_tool_runner.test_run_tool_holds_excludes_for_explicit_paths(mock_ci, mock_install_binary, mock_run, tmp_path, monkeypatch, name, flag, extra_args)[source]¶
A path named on the command line stays subject to the tool’s exclude list.
ruff and typos apply their exclude list only while they walk a directory, so a file passed by name is processed whatever the list says, unless the flag that holds the list comes with it.
- tests.test_tool_runner.test_run_tool_binary_forwards_extra_args(mock_ci, mock_install_binary, mock_run, tmp_path, monkeypatch)[source]¶
Extra args are appended after default flags for binary tools.
- tests.test_tool_runner.test_run_tool_binary_default_flags(mock_ci, mock_install_binary, mock_run, tmp_path, monkeypatch)[source]¶
Binary tools include default_flags in the command.
- tests.test_tool_runner.test_run_tool_ruff_bundled_default(mock_ci, mock_run, tmp_path, monkeypatch)[source]¶
ruff uses bundled default config when no config exists.
- tests.test_tool_runner.test_run_tool_ruff_reads_pyproject_natively(mock_ci, mock_run, tmp_path, monkeypatch)[source]¶
ruff gets no config file when [tool.ruff] exists in pyproject.toml.
- tests.test_tool_runner.test_run_tool_ruff_target_version(mock_ci, mock_run, tmp_path, monkeypatch, pyproject, native_file, expected)[source]¶
The bundled ruff config gets the
requires-pythonfloor astarget-version.Without it, ruff falls back to its oldest supported Python, and the safe
UPfixes rewrite code to an API the project’s floor lacks.
- tests.test_tool_runner.test_run_tool_bump_my_version_via_uvx(mock_ci, mock_run, tmp_path, monkeypatch)[source]¶
bump-my-version runs via uvx with subcommand extra_args.
- tests.test_tool_runner.test_resolve_config_reads_pyproject_with_section(tmp_path, monkeypatch)[source]¶
Tools with reads_pyproject=True skip translation when [tool.X] exists.
- tests.test_tool_runner.test_resolve_config_finds_a_table_named_apart_from_the_tool(tmp_path, monkeypatch)[source]¶
bump-my-version reads
[tool.bumpversion], not[tool.bump-my-version].
- tests.test_tool_runner.test_resolve_config_reads_pyproject_falls_through_to_bundled(tmp_path, monkeypatch, cache_env)[source]¶
Tools with reads_pyproject=True use bundled default when no config exists.
- tests.test_tool_runner.test_resolve_config_native_file_wins(tmp_path, monkeypatch)[source]¶
Native config file takes precedence over everything else.
- tests.test_tool_runner.test_resolve_config_pyproject_section(tmp_path, monkeypatch, cache_env)[source]¶
[tool.X] in pyproject.toml produces a cached config file.
- tests.test_tool_runner.test_resolve_config_toml_translation(tmp_path, monkeypatch, cache_env)[source]¶
[tool.X] with native_format=’toml’ produces a valid TOML cached file.
- tests.test_tool_runner.test_resolve_config_toml_nested_tables(tmp_path, monkeypatch, cache_env)[source]¶
Nested dicts in [tool.X] produce TOML table sections.
- tests.test_tool_runner.test_resolve_config_toml_preserves_pyproject_comments(tmp_path, monkeypatch)[source]¶
A [tool.X] TOML section materialised to a native file keeps its comments.
Reading the section live (not via a plain-dict copy) lets the generated standalone file carry the user’s comments while dropping the
[tool.X]prefix.
- tests.test_tool_runner.test_native_format_toml_serialize_reroots_section_and_keeps_comments()[source]¶
A live [tool.X] section loses its prefix and keeps every comment.
- tests.test_tool_runner.test_native_format_toml_serialize_inline_section()[source]¶
An inline
tool.x = {...}table serializes to the same data.
- tests.test_tool_runner.test_native_format_editorconfig_serialize_matches_every_file()[source]¶
A
[tool.shfmt]table becomes one[*]section of editorconfig keys.TOML hyphens turn to editorconfig underscores, and a boolean to lowercase.
- tests.test_tool_runner.test_resolve_config_json_translation(tmp_path, monkeypatch, cache_env)[source]¶
[tool.X] with native_format=’json’ produces a valid JSON cached file.
- tests.test_tool_runner.test_resolve_config_cwd_write_no_config_flag(tmp_path, monkeypatch)[source]¶
CWD-discovery tools write translated [tool.X] to the native config path.
- tests.test_tool_runner.test_resolve_config_no_config_flag_no_native_files_raises(tmp_path, monkeypatch)[source]¶
No config_flag and no native_config_files raises NotImplementedError.
- tests.test_tool_runner.test_resolve_config_bundled_default(tmp_path, monkeypatch, cache_env)[source]¶
Bundled default is cached and passed via –config flag.
- tests.test_tool_runner.test_resolve_config_bare_invocation(tmp_path, monkeypatch)[source]¶
Tool with no config at all gets bare invocation.
- tests.test_tool_runner.test_resolve_config_empty_tool_config_is_not_match(tmp_path, monkeypatch, cache_env)[source]¶
An empty [tool.X] table does not count as a config match.
- tests.test_tool_runner.BARE_TOOL = ToolSpec(name='sometool', display_name=None, version='1.0.0', package='sometool', module=None, native_config_files=(), config_flag=None, native_format=<NativeFormat.YAML: 'yaml'>, default_config=None, reads_pyproject=False, pyproject_table=None, default_flags=(), ci_flags=(), default_args=(), default_paths=None, per_file=False, with_packages=(), path_tools=(), needs_venv=False, install_into_venv=False, computed_params=None, prepare=None, config_after_subcommand=False, post_process=None, output_flag=None, problem_matcher=None, check_flags=(), rewrite_exit_code=None, binary=None, npm=None, source_url=None, tag_pattern=None, config_docs_url=None, cli_docs_url=None, docs_notes='')¶
A tool with no bundled default, no native file and no pyproject section.
- tests.test_tool_runner.test_config_source_label(tmp_path, monkeypatch, tool, files, expected)[source]¶
The reported config source names where the tool’s settings came from.
- tests.test_tool_runner.test_run_tool_unknown_tool()[source]¶
Raise ValueError for unregistered tool names.
- tests.test_tool_runner.test_run_tool_yamllint_bundled_default(mock_ci, mock_run, tmp_path, monkeypatch)[source]¶
yamllint with bundled default builds the correct command.
- tests.test_tool_runner.test_run_tool_ci_flags(mock_ci, mock_run, tmp_path, monkeypatch)[source]¶
CI flags are appended when GITHUB_ACTIONS is set.
- tests.test_tool_runner.test_run_tool_native_config_no_extra_flags(mock_ci, mock_run, tmp_path, monkeypatch)[source]¶
Tool with native config file gets no config flags from repomatic.
- tests.test_tool_runner.test_run_tool_pyproject_section_cached_config(mock_ci, mock_run, tmp_path, monkeypatch, cache_env)[source]¶
[tool.X] translation writes config to cache and passes via –config.
- tests.test_tool_runner.test_run_tool_forwards_exit_code(mock_ci, mock_run, tmp_path, monkeypatch)[source]¶
Tool’s exit code is forwarded unchanged.
- tests.test_tool_runner.test_run_tool_reports_a_launcher_missing_from_path(mock_ci, mock_run, tmp_path, monkeypatch)[source]¶
No
uvxonPATHraises the install error callers turn into a message.
- tests.test_tool_runner.test_run_tool_autopep8_default_flags(mock_ci, mock_run, tmp_path, monkeypatch)[source]¶
autopep8 runs with all default flags via uvx.
- tests.test_tool_runner.test_run_tool_pyproject_fmt(mock_ci, mock_run, tmp_path, monkeypatch)[source]¶
pyproject-fmt runs bare via uvx, with no forced –expand-tables flag.
- tests.test_tool_runner.test_run_tool_mdformat_with_packages(mock_ci, mock_install_binary, mock_run, tmp_path, monkeypatch)[source]¶
mdformat runs via uvx with all plugin packages.
- tests.test_tool_runner.test_run_tool_concurrent_runs_keep_their_cwd_config(mock_ci, mock_install_binary, cache_env, tmp_path, monkeypatch)[source]¶
Two runs sharing a directory each keep a written config for their whole run.
Without the lock, the second run took the first run’s temporary
.mdformat.tomlfor the repository’s own, then lost it halfway when the first run deleted it on the way out.
- tests.test_tool_runner.test_run_tool_runs_unlocked_when_the_cache_is_unwritable(mock_ci, mock_install_binary, mock_run, tmp_path, monkeypatch)[source]¶
A lock file that cannot be created does not stop the run.
- tests.test_tool_runner.test_store_config_falls_back_to_a_temp_file(tmp_path, monkeypatch)[source]¶
A cache that cannot be written still hands the tool its config.
The config goes to a temp file instead, returned for the caller to delete.
- tests.test_tool_runner.test_run_tool_mypy_with_computed_params(mock_ci, mock_metadata_cls, mock_run, tmp_path, monkeypatch)[source]¶
mypy runs via uv run with computed –python-version param.
- tests.test_tool_runner.test_run_tool_mypy_without_computed_params(mock_ci, mock_metadata_cls, mock_run, tmp_path, monkeypatch)[source]¶
mypy runs without computed params when Metadata returns None.
- tests.test_tool_runner.test_run_tool_mypy_no_lockfile_falls_back_isolated(mock_ci, mock_metadata_cls, mock_run, tmp_path, monkeypatch)[source]¶
Without a uv.lock, mypy runs isolated instead of demanding
--frozen.A repository holding a
pyproject.tomlwith only[tool.*]tables (a dotfiles repo linting standalone scripts) has no lockfile, souv run --frozenaborts with “Unable to find lockfile atuv.lock” before mypy ever starts.
- tests.test_tool_runner.test_mypy_version_floor_matches_the_pinned_mypy(tmp_path, monkeypatch)[source]¶
The pinned mypy accepts
MYPY_VERSION_MINand refuses the release before.mypy_paramsfloors--python-versionat this value, so a project that declares an olderrequires-pythonstill hands mypy a dialect it runs.
- tests.test_tool_runner.test_run_tool_nuitka_uses_module_invocation(mock_ci, mock_run, tmp_path, monkeypatch)[source]¶
nuitka runs via
python -m nuitkato avoid Windows script resolution issues.
- tests.test_tool_runner.test_run_tool_nuitka_nofollow_imports_default(mock_ci, mock_run, tmp_path, monkeypatch)[source]¶
nuitka excludes tkinter by default via nuitka.nofollow-imports.
- tests.test_tool_runner.test_run_tool_nuitka_gets_its_target_environment(mock_ci, mock_run, tmp_path, monkeypatch)[source]¶
The variables the prepare hook returns reach Nuitka, over the inherited ones.
- tests.test_tool_runner.test_prepare_failure_is_an_install_error()[source]¶
A preparation uv refuses ends the run like a failed install.
- tests.test_tool_runner.test_run_tool_nuitka_nofollow_imports_override(mock_ci, mock_run, tmp_path, monkeypatch)[source]¶
An explicit nuitka.nofollow-imports replaces the tkinter default.
- tests.test_tool_runner.test_run_tool_creates_output_parent_directory(mock_ci, mock_install_binary, mock_run, tmp_path, monkeypatch)[source]¶
run_tool creates parent directories for –output file paths.
- tests.test_tool_runner.test_run_tool_creates_output_parent_equals_form(mock_ci, mock_install_binary, mock_run, tmp_path, monkeypatch)[source]¶
The
--output=pathspelling gets its parent directory created too.
- tests.test_tool_runner.test_run_tool_output_existing_directory_is_noop(mock_ci, mock_install_binary, mock_run, tmp_path, monkeypatch)[source]¶
run_tool does not fail when –output parent directory already exists.
- tests.test_tool_runner.test_run_tool_no_output_flag_skips_mkdir(mock_ci, mock_run, tmp_path, monkeypatch)[source]¶
run_tool without –output does not create any directories.
- tests.test_tool_runner.test_find_unmodified_configs_exact_match(tmp_path, monkeypatch)[source]¶
Native config file matching bundled default is flagged as unmodified.
- tests.test_tool_runner.test_find_unmodified_configs_trailing_whitespace(tmp_path, monkeypatch)[source]¶
Trailing whitespace differences are normalized away.
- tests.test_tool_runner.test_find_unmodified_configs_honors_root(tmp_path, monkeypatch)[source]¶
Detection reads under
root, never the current directory.run_initjoins the returned paths against itsoutput_dir, so a scan anchored elsewhere would report on one tree and let--delete-unmodifieddelete from another.
- tests.test_tool_runner.test_find_unmodified_configs_modified_content(tmp_path, monkeypatch)[source]¶
Native config with different content is not flagged.
- tests.test_tool_runner.test_find_unmodified_configs_no_file(tmp_path, monkeypatch)[source]¶
No native config on disk returns empty list.
- tests.test_tool_runner.test_find_unmodified_configs_multiple_tools(tmp_path, monkeypatch)[source]¶
Redundant files for multiple tools are all detected.
- tests.test_tool_runner.test_find_unmodified_configs_alternative_filename(tmp_path, monkeypatch)[source]¶
Alternative native config filename (.yamllint.yml) is also checked.
- tests.test_tool_runner.test_directive_yaml_options_regex(before, after)[source]¶
YAML-block directive options are converted to field-list syntax.
- tests.test_tool_runner.test_directive_yaml_options_regex_no_false_positives(content)[source]¶
Non-directive YAML blocks and horizontal rules are left untouched.
- tests.test_tool_runner.test_fix_myst_directives_in_place(tmp_path)[source]¶
Post-processor rewrites files in-place and skips unchanged files.
- tests.test_tool_runner.test_fix_myst_directives_multiple_directives(tmp_path)[source]¶
Multiple directive blocks in the same file are all fixed.
- tests.test_tool_runner.test_escaped_colon_fence_regex(before, after)[source]¶
Escaped colon-fence directives are un-escaped, nesting included.
- tests.test_tool_runner.test_escaped_colon_fence_regex_no_false_positives(content)[source]¶
Unescaped fences, deflist syntax and stray escapes are left untouched.
- tests.test_tool_runner.test_fix_myst_directives_colon_fence_in_place(tmp_path)[source]¶
Both fixups run together: YAML options and escaped colon fences.
- tests.test_tool_runner.test_fix_myst_directives_skips_a_file_that_is_not_text(tmp_path)[source]¶
A file that does not decode as UTF-8 is not one mdformat wrote.
run_toolhands over every file whose content changed below a directory argument, whoever wrote it: an editor that refreshes.git/indexduring the run is enough. The page listed after the photo proves the loop goes on.
- tests.test_tool_runner.test_check_bypasses_post_process()[source]¶
Only a post_process tool in check mode bypasses post-processing.
- tests.test_tool_runner.test_run_tool_warns_when_check_bypasses_post_process(mock_ci, mock_install_binary, mock_run, tmp_path, monkeypatch, caplog)[source]¶
mdformat –check warns that the post-process fixup is skipped.
- tests.test_tool_runner.test_run_tool_no_check_warning_in_write_mode(mock_ci, mock_install_binary, mock_run, tmp_path, monkeypatch, caplog)[source]¶
mdformat in write mode (no check flag) emits no check-mode warning.
- tests.test_tool_runner.test_run_tool_warns_when_the_cwd_config_misses_a_target(mock_ci, mock_install_binary, mock_run, tmp_path, monkeypatch, caplog)[source]¶
mdformat names each target that its written config cannot reach.
mdformat looks for its config from each file’s directory up, so the
.mdformat.tomlwritten into the working directory misses a file outside it.
- tests.test_tool_runner.test_run_tool_no_cwd_config_warning_for_targets_inside(mock_ci, mock_install_binary, mock_run, tmp_path, monkeypatch, caplog)[source]¶
A file or directory below the working directory, and a flag, warn nothing.
- tests.test_tool_runner.test_run_tool_post_processes_files_below_a_directory(mock_ci, mock_install_binary, mock_run, tmp_path, monkeypatch)[source]¶
mdformat pointed at a directory gets its fixup on each file it rewrote.
A file the run left alone keeps its content. It stands for a file that the exclude list of the tool skipped, which the fixup must not rewrite either.
- tests.test_tool_runner.test_resolve_config_flags_format(tmp_path, monkeypatch)[source]¶
A FLAGS-format spec turns
[tool.X]into CLI args, not a file.
- tests.test_tool_runner.test_resolve_config_flags_format_empty(tmp_path, monkeypatch)[source]¶
No
[tool.X]section yields no flags and no cleanup file.
- tests.test_tool_runner.test_native_format_flags_serialize_raises()[source]¶
FLAGS is not a file format, so serialize() rejects it.
- tests.test_tool_runner.test_strip_components_resolves_per_platform()[source]¶
A dict
strip_componentsresolves likearchive_formatdoes.ghis the reason both exist: its Linux and macOS archives nest under a versioned directory while the Windows zip does not, so one count cannot serve every platform.
- tests.test_tool_runner.test_strip_components_plain_int_applies_everywhere()[source]¶
A bare
intkeeps applying to every platform, as before.
- tests.test_tool_runner.test_gh_spec_matches_upstream_archive_layout()[source]¶
gh’s declared layout matches what cli/cli actually publishes.Locks in the asymmetry that motivated per-platform
strip_components: a future release that flattened the Linux tarball, or nested the Windows zip, would extract the wrong path and only fail during a release.
- tests.test_tool_runner.test_resolve_default_args_without_defaults()[source]¶
A tool declaring none runs bare, exactly as before.
- tests.test_tool_runner.test_resolve_default_args_flags_only()[source]¶
A tool whose CI shape is a literal argument needs no inventory.
- tests.test_tool_runner.test_resolve_default_args_appends_the_inventory(tmp_path, monkeypatch)[source]¶
Declared paths resolve to the repository’s own matching files.
- tests.test_tool_runner.test_resolve_default_args_keeps_default_args_ahead_of_paths(tmp_path, monkeypatch)[source]¶
A subcommand stays the first token, where the tool’s parser wants it.
- tests.test_tool_runner.test_resolve_default_args_splits_per_file(tmp_path, monkeypatch)[source]¶
per_filemirrorsxargs -n1: one invocation per target.
- tests.test_tool_runner.test_resolve_default_args_empty_inventory_means_skip(tmp_path, monkeypatch)[source]¶
No matching file resolves to
None, never to a pathless invocation.This is the guard the whole feature exists for: a write-mode formatter handed zero paths walks the entire tree instead of doing nothing.
- tests.test_tool_runner.test_run_tool_skips_a_tool_with_no_targets(mock_ci, mock_run, mock_install_binary, tmp_path, monkeypatch)[source]¶
An empty inventory means the tool is never spawned.
- tests.test_tool_runner.test_run_tool_runs_once_per_file(mock_ci, mock_run, mock_install_binary, tmp_path, monkeypatch)[source]¶
A per-file tool is invoked once per target, installed once.
- tests.test_tool_runner.test_run_tool_reports_the_first_failure_across_batches(mock_ci, mock_run, mock_install_binary, tmp_path, monkeypatch)[source]¶
Every target still runs, and no later success masks an earlier failure.
- tests.test_tool_runner.test_run_tool_explicit_args_suppress_defaults(mock_ci, mock_run, mock_install_binary, tmp_path, monkeypatch)[source]¶
A caller-supplied argument means the caller drives the whole argv.
Without the all-or-nothing rule, biome’s
formatdefault would splice ahead of an explicitcheck, building a command neither one asked for.
- tests.test_tool_runner.test_default_paths_names_a_real_inventory_group(spec)[source]¶
A tool’s declared target group exists and yields paths.
The field is a string because the inventory resolves against the working directory at call time, so a typo would otherwise surface as an
AttributeErrormid-run, in CI, after the tool was already installed.
- tests.test_tool_runner.test_per_file_requires_default_paths(spec)[source]¶
per_filesplits a target list, so it is meaningless without one.
- tests.test_tool_runner.MESSY_PYPROJECT = '[project]\nname="orchard"\nversion="1.0"\n'¶
An unformatted
pyproject.toml, the input a formatter is expected to rewrite.
- tests.test_tool_runner.test_run_tool_reports_a_rewrite_status_that_rewrote_nothing(mock_ci, mock_run, mock_install_binary, tmp_path, monkeypatch, caplog)[source]¶
A formatter claiming a rewrite it did not perform is reported as a crash.
This is how pyproject-fmt dies on a
PanicException: exit code 1, the same one it uses for a successful reformat, and an untouched file. Callers have to tolerate that code, so without the file check the crash reads as a normal run and the autofix job goes green having formatted nothing.
- tests.test_tool_runner.test_run_tool_reports_success_for_a_rewrite_it_verified(mock_ci, mock_run, mock_install_binary, tmp_path, monkeypatch)[source]¶
The same exit code reports success when a file did change.
The rewrite is what the caller asked for, so no workflow step has to tolerate the code the formatter announces it with.
- tests.test_tool_runner.test_run_tool_leaves_other_tools_exit_codes_alone(mock_ci, mock_run, mock_install_binary, tmp_path, monkeypatch)[source]¶
A tool declaring no rewrite status keeps reporting its own failures.
mdformat exits 1 on a genuine error, never to announce a rewrite, so the contradiction check must not reinterpret it.
- tests.test_tool_runner.test_digest_targets_stays_out_of_git_directories(tmp_path, monkeypatch)[source]¶
A walk below a directory argument never enters a
.gitdirectory.No tool rewrites a file there, and another process can. An index that an editor refreshes during the run would read as a file the tool rewrote. A
.gitignorefile is not in that directory, and stays in the walk.
- tests.test_tool_runner.test_verify_via_write_path_propagates_a_crash(mock_run_tool, tmp_path, monkeypatch)[source]¶
A tool that dies on the copies is a failure, not a clean bill of health.
The copies come back unformatted, so comparing them to the originals finds no difference. Reporting that as “already formatted” would turn every crash into a passing verification.
- tests.test_tool_runner.test_verify_via_write_path_accepts_the_working_directory(mock_run_tool, tmp_path, monkeypatch)[source]¶
A path resolving to the working directory verifies the default set.
The scratch root is created inside the working directory, so mirroring
.under it makes the scratch its own copy destination andshutil.copytreedies on it as an existing path. It reached users as a bareFileExistsError: .repomatic-verify-<rand>, which reads as a repository problem rather than a rejected argument.The collision happens while copying, before the tool runs, so a stubbed
run_toolkeeps the test off the network.
- tests.test_tool_runner.test_verify_via_write_path_fails_when_nothing_is_copied(mock_run_tool, tool, extra_args, tmp_path, monkeypatch)[source]¶
A verification that copied no path measured nothing, so it cannot pass.
An exit code of
0would read as a clean tree to any gate running it.
- tests.test_tool_runner.test_verify_via_write_path_reports_a_path_it_cannot_copy(mock_run_tool, tmp_path, monkeypatch, caplog)[source]¶
A copy that fails is one logged error that names the path, not a traceback.
Nothing was measured, so the answer is the
2of a call that copied no path, and the scratch directory does not outlive the call.
- tests.test_tool_runner.test_verify_via_write_path_copies_a_directory_and_an_outside_file(tmp_path, monkeypatch)[source]¶
A directory is copied whole, a file outside the tree under its own name.
The check flag is dropped: it would stop the write path the comparison reads. Each file of the directory is compared on its own.
- tests.test_tool_runner.test_verify_via_write_path_returns_the_diff_of_each_rewrite(before, after, expected, tmp_path, monkeypatch)[source]¶
Each rewritten path comes back with the unified diff of its rewrite.
A last line with no newline is marked as
diff -umarks it, so it does not run into the line after it. A file that is not UTF-8 text gets a note.
- tests.test_tool_runner.test_verify_via_write_path_without_targets_has_nothing_to_verify(mock_run_tool, tmp_path, monkeypatch)[source]¶
A bare call in a tree holding none of the tool’s files is clean, as
runis.
- tests.test_tool_runner.test_run_rejects_an_unknown_tool_as_a_usage_error()[source]¶
An unknown tool name is refused at parse time, naming the registry.
It used to reach
run_tooland raise a bareValueError, so a typo printed a Python traceback instead of a usage error.
- tests.test_tool_runner.test_run_reports_an_install_failure_as_an_error(mock_install_binary, tmp_path, monkeypatch)[source]¶
A tool that cannot be installed ends the run with a message, not a traceback.
- tests.test_tool_runner.test_run_lists_every_tool_with_its_pinned_version(tmp_path, monkeypatch)[source]¶
--listprints each tool beside its pin, and runs none of them.
- tests.test_tool_runner.HARVEST_DIFF = '--- harvest.md\n+++ harvest.md\n@@ -1 +1,2 @@\n # Mango\n+Ripe.\n'¶
Diff of a rewrite that adds a line to
harvest.md.
- tests.test_tool_runner.test_run_verify_names_each_file_it_would_rewrite(mock_verify, tmp_path, monkeypatch)[source]¶
--verifyprints each drifted file with its diff, and exits with the verdict.The diff follows its
Would rewrite:line on the standard output, and the log stays free of it.