Skip to content

Make the Narrowed-Scan Diff-Floor Test Independent of the Working Directory #2830

Closed

Description

@ptr727

Defect

tests/test_prose_lint.py TestDiffScopeFloor.test_a_deliberately_narrowed_scan_is_not_told_the_narrowing_is_a_defect passes only when the test process's working directory contains an entry named catalog.

The test narrows the scan with the bare relative path catalog, and it mocks repo_root, discover, and changed_lines. It never creates catalog under its temporary root. Before the diff-floor logic runs, prose_lint.main refuses any requested path that is neither a file nor a directory relative to the working directory, and returns 2. The hub's root happens to have a tracked catalog/ directory, so a run from the root passes and a run from anywhere else fails with 0 != 2. The floor logic under test is not at fault.

Repro

From a clean develop checkout:

  • cd tests && python3 -m unittest test_prose_lint.TestDiffScopeFloor.test_a_deliberately_narrowed_scan_is_not_told_the_narrowing_is_a_defect fails with AssertionError: 0 != 2.
  • python3 -m unittest discover -s tests -p test_prose_lint.py -k narrowed, run from the root, passes.

CI and the file's own header both run from the root, so CI stays green, and the defect shows up only in a local run started elsewhere.

Proposed fix

Make the test self-contained: create self.tmp / "catalog" and pass str(self.tmp / "catalog") as the narrowing argument, so the path resolves against the mocked root rather than the working directory. Check the sibling tests that pass a relative path for the same dependence.

Activity

  1. added
    bugSomething isn't working
    gateA rule with no mechanical check, or a check that misses a shape
    on Oct 11, 2026
  2. added a commit that references this issue on Oct 11, 2026
    9f60eb8
  3. added a commit that references this issue on Oct 12, 2026
    687d5bd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggateA rule with no mechanical check, or a check that misses a shape

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions