Commit 2dcda8b
authored
* test: add 199 unit tests for granite formatters (#812)
Unit tests for Granite 3.2 and 3.3 input/output processors, shared
utilities, IntrinsicsResultProcessor canned data regression, and
OpenAI SDK compatibility. No GPU, network, or model downloads required.
- test_granite3_shared.py: find_substring_in_text, create_dict,
parse_hallucinations_text, hallucination/citation span helpers
- test_granite32_output.py: citation parsing, model output splitting,
validation, transform pipeline
- test_granite33_output.py: JSON-delimited citations/hallucinations,
think/response extraction, controls cleanup
- test_granite32_input.py: system message matrix, sanitize, transform
- test_granite33_input.py: available_tools role, per-document roles
- test_intrinsics_canned_output.py: canned model outputs through
IntrinsicsResultProcessor, Pydantic schema validation of fixtures
- test_openai_compat.py: ChatCompletion round-trip through OpenAI SDK
Closes #812
* test: remove test_empty_substring (tests stdlib not our code)
* fix: nltk_check() now catches LookupError for missing punkt_tab data
nltk_check() only caught ImportError (package not installed) but missed
LookupError (package installed, data not downloaded). Users with nltk
present via transitive deps (rouge_score) got an unhelpful ValueError
instead of install instructions when punkt_tab was missing.
Also adds punkt_tab download to CI workflow — same pattern as Ollama
model pulls.
* fix: declare nltk as explicit dependency
nltk is required by granite citation/hallucination parsing
(nltk.sent_tokenize) but was only present as a transitive dependency
of rouge_score. Pin >=3.9 for punkt_tab support (security fix over
pickle-based punkt).
* fix: code review cleanups for granite formatter tests
- Fix granite_io → mellea in nltk_check error message (copy-paste from upstream)
- Consolidate duplicate nltk_check into optional.py (single source of truth)
- Remove unused imports in test_granite32_output.py
- Fix assertion logic in test_balanced_tags_no_warnings (or → and)
* test: harden granite test robustness
- Fix invalid TCP port 98765 → 127.0.0.1:1 in OpenAI compat test
- Add assertions that testdata directories are non-empty (fail loudly
instead of silently collecting zero test cases)
- Add unit tests for nltk_check LookupError handling
* fix: address PR #818 review comments
- Replace stale granite_io reference with mellea in optional.py docstring
- Use record-level caplog assertions in granite32 output tests for
consistency with granite33 tests
* fix: address code review findings
- Fix stale granite_io reference in util.py import_optional docstring
- Tighten test_missing_colon_skipped assertion to verify empty result
1 parent 25745b7 commit 2dcda8b
14 files changed
Lines changed: 1794 additions & 36 deletions
File tree
- .github/workflows
- mellea/formatters/granite
- base
- granite3
- granite32
- granite33
- test/formatters/granite
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
| 44 | + | |
| 45 | + | |
44 | 46 | | |
45 | 47 | | |
46 | 48 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
30 | | - | |
| 30 | + | |
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
| |||
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
52 | | - | |
53 | | - | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
54 | 56 | | |
55 | 57 | | |
56 | 58 | | |
57 | 59 | | |
58 | 60 | | |
59 | 61 | | |
60 | | - | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
61 | 68 | | |
62 | 69 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | 26 | | |
35 | 27 | | |
36 | 28 | | |
37 | 29 | | |
38 | 30 | | |
39 | 31 | | |
40 | 32 | | |
41 | | - | |
| 33 | + | |
42 | 34 | | |
43 | 35 | | |
44 | 36 | | |
| |||
52 | 44 | | |
53 | 45 | | |
54 | 46 | | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | 47 | | |
77 | 48 | | |
78 | 49 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
| 43 | + | |
43 | 44 | | |
44 | | - | |
| 45 | + | |
45 | 46 | | |
46 | 47 | | |
47 | 48 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| 28 | + | |
28 | 29 | | |
29 | | - | |
| 30 | + | |
30 | 31 | | |
31 | 32 | | |
32 | 33 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
| 31 | + | |
31 | 32 | | |
32 | 33 | | |
33 | 34 | | |
| |||
0 commit comments