Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

🐛 sphinx-test-reports: a need from a generated test file records the expanded input's line as its lineno, not the page's

Open Beginner friendly
#2,209 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
72/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
python
Domain
documentation

Research direction

Start with directives/test_file.py around line 148, where self.lineno is passed to add_need, and compare with the warning-location mapping in directives/test_report.py lines 119-128. Run tests/test_need_directive_errors.py, the second-test-report-of-one-id case, to see the pinned lineno of 44. Done when every need generated from a test-report on line N reads back from needs.json with lineno N and that expectation is updated.

Written by the indexing model from the issue text.

Description

bug pkg: sphinx-test-reports

What happens

A need created from a generated test file (test-report expanding into test-file / test-suite / test-case directives) records a lineno that is not a line of the page it is on. On a ten-line page holding two test-report directives for one :id:, the kept need's lineno is 44, and since sphinx-needs #2189 a duplicate is refused with the location of the kept need, so the warning reads:

Need could not be created: A need with ID 'TR_ONE' already exists (defined at index:44).

index.rst has no line 44. The suite pins that number exactly (tests/test_need_directive_errors.py, the second-test-report-of-one-id case), so this issue's fix moves that expectation.

Why

directives/test_file.py:148 passes self.lineno to add_need, and for a directive the expansion inserted, that is its line in the EXPANDED input (the generated lines count), not the page's. directives/test_report.py:119-128 re-attributes the inserted lines' SOURCE for warnings, but the line handed to add_need is not mapped. Measured on master before #2189 as well: the need, its suite and its case all record 44.

Fix

Pass the mapped line (the test-report directive's own line on the page, which is what a reader can open) to add_need for every need the expansion creates, the way the warning location is already mapped; then update the pinned expectation to the page's line. A unit case: a page with a test-report on line N and the generated needs read back from needs.json all carry lineno == N.

Dominant language
Python
Stars
309
Forks
103
Avg merge
4h 40m
Merged PRs (30d)
154

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from useblocks/sphinx-needs

All issues in useblocks/sphinx-needs

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.