tests.test_dep_policy moduleΒΆ

Tests for the dependency-declaration policy checks.

tests.test_dep_policy.write_pyproject(tmp_path, body)[source]ΒΆ

Write a pyproject.toml holding body and return its path.

tests.test_dep_policy.remedies(findings)[source]ΒΆ

The remedy of each finding, for a terse assertion.

Return type:

list[str]

tests.test_dep_policy.write_lock(tmp_path, requested, resolved)[source]ΒΆ

Write a uv.lock in which orchard selects requested extras of papaya.

Parameters:

resolved (list[str] | None) – The extras the papaya entry resolves to a package, or None to leave papaya out of the lock.

tests.test_dep_policy.test_policy_accepts(tmp_path, body, threshold)[source]ΒΆ

A declaration that follows every rule produces no finding.

tests.test_dep_policy.test_upper_bound_on_a_runtime_dependency(tmp_path)[source]ΒΆ

A cap propagates to everyone installing this project.

tests.test_dep_policy.test_a_file_under_another_name_is_scanned(tmp_path)[source]ΒΆ

lint-deps --pyproject can name any file, and that file is the one read.

A scan reading the pyproject.toml beside the named file would report nothing at all for a file named anything else.

tests.test_dep_policy.test_a_header_with_a_comment_opens_its_table(tmp_path)[source]ΒΆ

A comment after a table header does not hide the table it opens.

The array below it is reported under that table, and never under the table above, which may hold an array of the same name.

tests.test_dep_policy.test_every_capping_operator_is_caught(tmp_path, specifier)[source]ΒΆ

~= counts: it implies a ceiling even without a < in it.

tests.test_dep_policy.test_policy_flags_a_floor_problem(tmp_path, body, remedy)[source]ΒΆ

A missing or undocumented floor draws the remedy that fixes it.

tests.test_dep_policy.test_unsorted_list_names_only_the_first_offender(tmp_path)[source]ΒΆ

One misplaced entry makes every later one look wrong too.

tests.test_dep_policy.test_type_stub_outside_the_typing_group(tmp_path)[source]ΒΆ

A stub reaching a runtime environment is pure weight.

tests.test_dep_policy.SELECTS_PAPAYA_EXTRAS = '[project]\nname = "orchard"\ndependencies = [\n  # papaya 3.0 ships the peel() the harvest report calls.\n  "papaya[juice,seeds]>=3",\n]\n'ΒΆ

A project selecting two extras of papaya, for the lock to judge.

tests.test_dep_policy.test_extra_that_installs_nothing(tmp_path, requested, resolved, expected)[source]ΒΆ

An extra the lock resolves to no package draws the remedy to drop it.

tests.test_dep_policy.test_extras_are_judged_only_against_a_given_lock(tmp_path)[source]ΒΆ

A caller passing no lock gets the pyproject.toml rules alone.

tests.test_dep_policy.test_missing_file_reports_nothing(tmp_path)[source]ΒΆ

A non-Python repo has nothing to check, and must not raise.

tests.test_dep_policy.test_comment_word_count_ignores_markers(comment, words)[source]ΒΆ

The # is stripped before counting; everything else counts.

tests.test_dep_policy.test_over_long_floor_comment_is_flagged(tmp_path)[source]ΒΆ

A comment that narrates every past floor buries the current one.

tests.test_dep_policy.test_a_block_comment_excuses_absence_but_not_length(tmp_path)[source]ΒΆ

A preamble above the array would otherwise silence every entry.

The escape hatch exists so a run of related entries can be justified in one block. Reading it as a blanket pass makes any project whose array carries a policy preamble unscannable, which is how meta-package-manager accumulated a 676-word floor comment.

tests.test_dep_policy.test_a_wall_moved_above_the_array_is_still_a_wall(tmp_path)[source]ΒΆ

Moving the comment up one line must not buy an exemption.

Reported once, against the first entry leaning on the block, rather than once per entry: it is one comment to rewrite.

tests.test_dep_policy.test_this_repository_follows_its_own_policy()[source]ΒΆ

The canonical reference has to pass the rules it ships.

Downstream repos mirror this file’s conventions, so a finding here is either real drift or a rule too strict to be worth enforcing. Run at the configured default rather than at the disabled-by-default 0, since the threshold is exactly the rule most likely to drift back.