Skip to content

Commit

Permalink
🐛 FIX need_count infinite ratio (#1324)
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisjsewell authored Oct 10, 2024
1 parent fa937f2 commit fa2f32c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion sphinx_needs/roles/need_count.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def process_need_count(
need_list, needs_config, filters[1], location=node_need_count
)
)
amount = f"{amount_1 / amount_2 * 100:2.1f}"
amount = "inf" if amount_2 == 0 else f"{amount_1 / amount_2 * 100:2.1f}"
elif len(filters) > 2:
raise NeedsInvalidFilter(
"Filter not valid. Got too many filter elements. Allowed are 1 or 2. "
Expand Down
4 changes: 4 additions & 0 deletions tests/doc_test/doc_need_count/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,7 @@ result_1-:need_count:`"A" in tags`
result_2-:need_count:`"B" in tags`

result_3-:need_count:`True`

result_4-:need_count:`"A" in tags ? "B" in tags`

result_5-:need_count:`"A" in tags ? "X" in tags`
2 changes: 2 additions & 0 deletions tests/test_need_count.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@ def test_doc_need_count(test_app):
assert "result_1-3" in html
assert "result_2-2" in html
assert "result_3-4" in html
assert "result_4-1" in html
assert "result_5-inf" in html

0 comments on commit fa2f32c

Please sign in to comment.