tests.test_uv module¶
Tests for the audit command and the cooldown-bypass machinery behind it.
audit reports by default and upgrades with --fix. The
exclude-newer-package lifecycle lives in repomatic.deps.uv,
repomatic.deps.lockfile and repomatic.deps.cooldown.
The repomatic.deps.report renderers these helpers feed are covered by
tests/test_dep_report.py’s golden renders.
- tests.test_uv.NOW = datetime.datetime(2026, 10, 20, 12, 0, tzinfo=datetime.timezone.utc)¶
A fixed instant for the tests whose expectations depend on the clock.
- tests.test_uv.test_cooldown_windows_match_minimum_release_age()[source]¶
The lock window and the install window are the same duration.
[tool.uv] exclude-newergatesuv lock, while [tool.repomatic] minimum-release-age``gates the``uvx installs every workflow runs. A lock window wider than the install window resolves versions those installs then refuse, leaving a package pinned inuv.lockthat CI cannot install. Keeping the two literals equal closes that band.- Return type:
- tests.test_uv.default_config(monkeypatch)[source]¶
Pin the command to dataclass-default config, independent of the repo.
- tests.test_uv.test_audit_report_lists_vulnerabilities_and_exits_nonzero(monkeypatch, default_config)[source]¶
- tests.test_uv.test_audit_report_does_not_call_the_fix_engine(monkeypatch, default_config)[source]¶
Report mode is read-only: it must never reach the upgrade path.
- tests.test_uv.test_audit_passes_configured_sources_without_repo(monkeypatch, default_config)[source]¶
Without a repository, the command still hands over every configured source.
Skipping the GitHub Advisory Database is the library’s call, made where the query would run, so the command passes the list through untouched.
- tests.test_uv.test_audit_github_only_sources_without_repo_query_nothing(monkeypatch, args, expected)[source]¶
A GitHub-only source list without a repository runs no
uv audit.The one configured source cannot run without a repository, so the list the library acts on is empty. An empty list must not read as “every source”, or the run falls back to the database the configuration left out.
- tests.test_uv.test_audit_fix_delegates_to_engine(monkeypatch, default_config, tmp_path)[source]¶
The upgrade report reaches both the terminal and the
--outputfile.
- tests.test_uv.test_audit_fix_reports_an_engine_failure(monkeypatch, default_config, error, message)[source]¶
A fix that cannot run ends the command on its message, not a traceback.
- tests.test_uv.test_audit_fix_skipped_when_sync_disabled(tmp_path, monkeypatch)[source]¶
vulnerable-deps.sync = falseinpyproject.tomlturns the fix off.
- tests.test_uv.test_uv_lock_command(extra, window, expected)[source]¶
The project’s window rides after the extra arguments, when it has one.
- tests.test_uv.test_run_uv_captures_output_and_carries_stderr()[source]¶
A failure raises with the command’s stderr, which it captured.
- tests.test_uv.test_run_uv_without_check_returns_the_failure()[source]¶
uv auditexits non-zero when it finds something: the caller reads it.
- tests.test_uv.test_run_uv_reports_a_command_that_cannot_start(check)[source]¶
No
uvonPATHraises the error every caller handles, whatevercheck.
- tests.test_uv.test_relock_is_a_plain_lock()[source]¶
A version bump refreshes the lock, never upgrades a dependency in it.
No
--upgrade, and no explicit window: the bump relocks with the project’s own settings, exactly as the workflow’suv locksteps do.
- tests.test_uv.test_exemption_value_pins_a_bare_date_to_utc()[source]¶
uv expands a bare date to the next UTC midnight: the pin writes that.
- tests.test_uv.test_prune_returns_pruned_names(tmp_path)[source]¶
An entry whose held version aged past the cutoff is dropped by name.
- tests.test_uv.test_prune_keeps_active_freeze(tmp_path)[source]¶
A freeze whose held version is still inside the window stays put.
- tests.test_uv.test_prune_under_a_zero_window(tmp_path, window, caplog)[source]¶
A disabled cooldown prunes every entry its lock ages, without a warning.
0 daysonce parsed to no window at all: the pass warned it could not parse the value and pruned nothing, on every run.
- tests.test_uv.YESTERDAY = 'yesterday'¶
Stands for a cutoff one day old, resolved in the test body.
A timestamp computed at collection differs between xdist workers.
- tests.test_uv.test_prune_ages_an_entry_the_lock_does_not_hold_by_its_cutoff(tmp_path, entry, packages, pruned)[source]¶
A package outside the lock has no held version, so its cutoff ages.
Once the rolling cutoff has passed a fixed timestamp, the entry admits no release the cooldown still withholds, and it blocks every later one.
- tests.test_uv.test_prune_matches_a_lock_name_in_any_spelling(tmp_path)[source]¶
An entry keyed by another spelling of the name still finds its release.
- tests.test_uv.test_prune_leaves_a_comment_naming_the_pruned_entry(tmp_path)[source]¶
A partial prune keeps the table’s comment, which still names the entry.
- tests.test_uv.test_comment_mentions(tmp_path, uv_lines, names, expected)[source]¶
Only the comments attached to
exclude-newer-packageare searched.
- tests.test_uv.test_freeze_returns_frozen_names(tmp_path)[source]¶
A relative-span bypass is rewritten to hold the locked version.
- tests.test_uv.test_freeze_reads_a_false_lift_as_a_zero_span(tmp_path)[source]¶
uv’s
falselifts the cooldown the way a zero span does, so it freezes.Read as the string
False, the entry would be unparsable: the freeze would leave it tracking the latest release, and the forecast give it an expiry.
- tests.test_uv.test_freeze_pins_bare_date(tmp_path)[source]¶
A legacy bare date is pinned to the equivalent explicit UTC instant.
- tests.test_uv.test_freeze_keeps_span_without_upload_time(tmp_path)[source]¶
A git/path package has no release to freeze against: span kept as-is.
- tests.test_uv.test_freeze_window_absorbs_same_day_patch(tmp_path)[source]¶
A freeze holds a day-granular window, not a single version.
The cutoff rounds up to the second UTC midnight after the held version’s upload, so a patch released later the same day (or on the next calendar day) stays inside the window and is adopted on the next lock. This is the accepted trade-off documented on
freeze_cutoff_after: pinning the cutoff to the exact upload instant is the only way to reject a same-day patch, so locking the window width here makes any such tightening a conscious change.
- tests.test_uv.LOCK_NAME_SPELLINGS = ('lemon-curd', 'lemon_curd', 'Lemon_Curd', 'LEMON-CURD')¶
Spellings of one package name under PEP 503. The first is the one uv locks.
- tests.test_uv.test_freeze_matches_a_lock_name_in_any_spelling(tmp_path, key)[source]¶
A span keyed by another spelling of the name is frozen like any other.
A lookup by the raw key finds no upload time, reads the package as a git or path source, and leaves the span to track the latest release for good. The entry keeps the key the project wrote.
- tests.test_uv.test_exempt_freezes_a_fresh_release_in_any_spelling(tmp_path, name)[source]¶
A package exempted under another spelling of its name gets a freeze.
A lookup by the raw name finds no upload time, and the entry falls back to the permanent
"0 day"span of a git or path source.
- tests.test_uv.test_exempt_skips_an_aged_release_in_any_spelling(tmp_path, name)[source]¶
A release that cleared the window needs no exemption in any spelling.
A lookup by the raw name finds no upload time, and the package is exempted like a git or path source.
- tests.test_uv.test_exempt_nothing_under_a_zero_window(tmp_path, window)[source]¶
With the cooldown disabled, no fix needs an exemption to resolve.
0 daysonce parsed to no window at all, which exempted every upgrade.
- tests.test_uv.test_settings_save_writes_only_a_change(tmp_path)[source]¶
Loading and saving untouched settings leaves the file alone.
- tests.test_uv.test_settings_never_create_a_missing_file(tmp_path)[source]¶
A project with no
pyproject.tomlhas no table to edit.
- tests.test_uv.test_active_forecasts_report_freezes_only(tmp_path)[source]¶
Fixed-timestamp entries get an expiry; spans do not.
- tests.test_uv.test_active_forecasts_flag_unreleased_hold(tmp_path)[source]¶
A freeze holding a version with no upload time can only end by release.
- tests.test_uv.test_pruned_forecasts_snapshot_cleared_freezes(tmp_path)[source]¶
Pruned entries keep the version and the (past) date the freeze aged out.
- tests.test_uv.test_pruned_forecasts_date_an_unlocked_entry_by_its_cutoff(tmp_path)[source]¶
A cleared entry of a package outside the lock keeps its cutoff’s expiry.
- tests.test_uv.test_held_back_probe_captures_uv_and_restores_the_lock(tmp_path)[source]¶
The probe runs under a progress trail: uv’s output must not stream.
Streamed, the probe’s own
uv lockwould print its resolution summary straight onto the trail’s spinner row.
- tests.test_uv.test_held_back_probe_dates_a_capped_release_by_its_capper(tmp_path)[source]¶
A release out of its window moves with the held release that caps it.
papaya1.10left its window weeks ago, but the lockedmango1.0caps it. The probe lifts every window at once and moves both, sopapayabecomes lockable whenmango1.10does, not on a date already past.
- tests.test_uv.test_held_back_probe_leaves_an_unexplained_hold_undated(tmp_path)[source]¶
A release out of its window, with no held neighbor, gets no date.
- tests.test_uv.test_held_back_probe_failure_reports_nothing(tmp_path)[source]¶
A probe that cannot resolve skips the section and keeps the lock.
- tests.test_uv.test_uv_error_is_a_called_process_error()[source]¶
Callers catching the standard error keep working.
- tests.test_uv.test_lock_specifiers_isolate_unconditional_declarations()[source]¶
by_mainholds only what a plain install of the project pulls in.A version marker leaves a dependency unconditional; an extra marker moves it to that extra’s box wherever it sits in the expression; a dev group never lands there at all.
- Return type:
- tests.test_uv.test_lock_specifiers_label_an_edge_with_the_unconditional_floor()[source]¶
A package declared unconditionally keeps that floor in
by_package.An extra or a dev group can declare the same package with a higher floor. Each box keeps its own floor, and the edge a plain install draws keeps the unconditional one. A package declared with no specifier carries no label, whatever floor an extra or a group gives it.
- Return type:
- tests.test_uv.test_lock_specifiers_skip_what_names_no_package()[source]¶
An entry that names no package, or is not a table, lands in no view.
A declaration naming a package without a specifier still counts: it is kept with an empty specifier, which only the edge-label view leaves out.
- Return type:
- tests.test_uv.test_lock_empty_extras_hold_what_installs_nothing()[source]¶
An extra the project selects, and the lock resolves to no package.
uv leaves such an extra out of
optional-dependencies. A package locked at two versions keeps an extra that either one resolves, and a package the lock does not hold is not judged.- Return type:
- tests.test_uv.test_lock_reads_an_absolute_exclude_newer_as_written()[source]¶
A cutoff the lock records as an instant needs no span to resolve.
- Return type:
- tests.test_uv.test_lock_views_of_a_missing_file(tmp_path)[source]¶
A lock that does not exist yet reads as an empty one.
- tests.test_uv.CHERRY_LOCK = 'version = 1\nrevision = 3\nrequires-python = ">=3.11"\n\n[[package]]\nname = "basket"\nversion = "1.0.0"\nsource = {{ editable = "." }}\ndependencies = [{{ name = "cherry" }}]\n\n[[package]]\nname = "cherry"\nversion = "{version}"\nsource = {{ registry = "https://pypi.org/simple" }}\nsdist = {{ url = "https://files.example.com/cherry-{version}.tar.gz", upload-time = "{uploaded}" }}\n'¶
A
uv.lockholding the project andcherry, with blanks for its release.
- tests.test_uv.locked_basket(tmp_path, monkeypatch)[source]¶
A project locking
cherryat1.0.0, as the working directory.
- tests.test_uv.test_sync_uv_lock_reports_each_upgrade(locked_basket)[source]¶
An upgraded package prints in the table and lands in the report.
- tests.test_uv.test_sync_uv_lock_without_upgrade_changes_nothing(locked_basket)[source]¶
A re-lock that moves no version reports no change.
- tests.test_uv.test_sync_uv_lock_reports_a_failed_lock_and_restores_the_project(locked_basket)[source]¶
A failed
uv lockends on uv’s error, with the project as it was found.