Fix spaced pytest node ID parsing - #92
karatarassul4-max wants to merge 1 commit into
Conversation
KNambiarDJsc
left a comment
There was a problem hiding this comment.
Thanks for picking up #90. For maintainers comparing this with #91, which fixes the same issue: I ran both against real pytest 9.0.3 output, using per-test outcomes recorded through a pytest_runtest_logreport hook as ground truth. I also swapped the test suites between the two branches.
Issues I found here:
1. CI lint will fail. ruff check . reports I001 (unsorted imports) in tests/test_pytest_spaced_node_ids.py. ruff check --fix resolves it.
2. Verbose skip lines are no longer parsed. pytest prints the skip reason in -v mode:
test_cases.py::test_skip[x] SKIPPED (needs optional dep) [ 94%]
_VERBOSE_RE only allows [ NN%] after the status, so these lines stop matching and skipped tests vanish from the status map. main records them as SKIPPED. With -rA, the short summary only has the folded SKIPPED [2] file:line: reason form. That now becomes the key test_cases.py:26: needs optional dep instead of test_cases.py:26:.
3. An unbalanced [ in a parameter keeps the diagnostic in the name. _strip_summary_diagnostic counts bracket depth, so with a parameter like "unmatched [ bracket" the depth never returns to 0. The summary line then yields this key:
test_cases.py::test_fail[unmatched [ bracket] - AssertionError: boom [unmatched [ bracket] - detail
In the verifier, that key counts as an untracked FAILED test.
4. console_output_style = count / times. The line ends in [ 8/17] or 415.6us, so no verbose line matches and only FAILED summary lines are parsed. main handles these for ordinary names. #91 has the same issue; I suggested a fix there.
5. Performance. The greedy .+ backtracks through pytest's right-aligned padding. A 100k-line log takes ~4.4s, against 0.13s on main and 0.4s on #91.
Also, the first commit deletes the verifier's if __name__ == "__main__" block and __all__, and the second restores them. The net diff is fine; just flagging it in case of a non-squash merge.
Since #91 covers these cases and has broader tests, including a real pytest run and a standalone-verifier subprocess, it may be simplest to consolidate on #91.
086dfdb to
ba0301f
Compare
|
Thanks for the detailed comparison and adversarial cases — they were very helpful. I've updated this PR to address the issues you found:
I also expanded the regression coverage for both the canonical parser and the standalone runtime verifier, including the non-default console styles and the edge cases above. The branch is now squashed to a single commit to avoid the intermediate-history concern. Thanks again for testing both implementations. |
|
Thanks for the thorough update. I re-ran the same checks on ba0301f. Against real pytest 9.0.3 output, all 19 of my cases now parse correctly under A few things are left. The first two would make CI red; I ran this on Linux with py3.12:
For maintainers: #91 now covers these cases, including the |
de3bed8 to
e96583d
Compare
|
Thanks for the follow-up and for checking these against real pytest output. I've addressed the remaining cases:
I added regression coverage for these cases in both the canonical parser and standalone runtime verifier, and kept the branch squashed to a single commit. The latest CI run is currently showing Thanks again for the thorough adversarial testing. |
|
Sure!
|
|
I re-ran everything on e96583d, and all the functional issues are fixed:
One thing would still fail the CI lint job.
Running |
Summary
Preserve full parametrized pytest node IDs when they contain spaces in both the canonical pytest log parser and the standalone runtime verifier.
The previous implementation used
\S+for verbose output andsplit()for summary lines, which truncated or dropped node IDs such astests/test_calc.py::test_eval[1 + 1].This change:
-remain intact;Closes #90