Skip to content

test: add negative scenario tests for AnchorLinkValidator to prevent NameError regressions #2

Description

@Nokhrin

Problem

During manual execution of the validator, a NameError was discovered in src/docs_validator/rules/anchor_link.py:

message=f'Anchor "{link.anchor}" not found in file {target_file_path.relative_to(root_dir)}'

The variable target_file_path is undefined (it should be target_path). This bug was not caught by the existing test suite because the current integration test (test_anchor_file.py) only covers the positive scenario (when the anchor exists and no issues are generated).

Proposed Solution

Add integration/unit tests to tests/integration/test_anchor_file.py (or a dedicated test file) to cover the negative scenarios:

  1. Target file exists, but the specified anchor is missing.
  2. Target file does not exist (should be handled gracefully or delegated to BrokenLinkValidator).

Activity

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

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions