Feature: Python log matcher
Scenario: Python traceback matcher compiles from YAML
Given I use the Python traceback matcher
Then compilation succeeds
And the result contains matcher with id "python.traceback"
And the matcher "python.traceback" has priority 100
Scenario: Full traceback emits one issue with location
Given I use the Python traceback matcher
When I process the line "Traceback (most recent call last):"
And I process the line ' File "main.py", line 10, in <module>'
And I process the line " x = 1 / 0"
And I process the line "ZeroDivisionError: division by zero"
And I flush the engine
Then the engine emitted 1 issue
And the issue message is "ZeroDivisionError: division by zero"
And the issue file is "main.py"
And the issue line is 10
And the issue severity is "error"
Scenario: Traceback without code line still emits issue
Given I use the Python traceback matcher
When I process the line "Traceback (most recent call last):"
And I process the line ' File "main.py", line 10, in <module>'
And I process the line "ZeroDivisionError: division by zero"
And I flush the engine
Then the engine emitted 1 issue
And the issue message is "ZeroDivisionError: division by zero"
And the issue file is "main.py"
And the issue line is 10
# The engine captures the first encountered File frame (lib.py) because
# body rule 1 (code-absorber) consumes subsequent File lines as noise.
# This is a documented v1 limitation: only the first frame's location
# is reported for multi-frame tracebacks.
Scenario: Multi-frame traceback captures first frame location
Given I use the Python traceback matcher
When I process the line "Traceback (most recent call last):"
And I process the line ' File "lib.py", line 42, in func'
And I process the line " do_something()"
And I process the line ' File "main.py", line 10, in <module>'
And I process the line " x = 1 / 0"
And I process the line "ZeroDivisionError: division by zero"
And I flush the engine
Then the engine emitted 1 issue
And the issue message is "ZeroDivisionError: division by zero"
And the issue file is "lib.py"
Scenario: Consecutive tracebacks produce two issues
Given I use the Python traceback matcher
When I process the line "Traceback (most recent call last):"
And I process the line ' File "a.py", line 1, in <module>'
And I process the line "ExceptionA: error A"
And I process the line "Traceback (most recent call last):"
And I process the line ' File "b.py", line 2, in <module>'
And I process the line "ExceptionB: error B"
And I flush the engine
Then the engine emitted 2 issues total
And issue 1 has message "ExceptionA: error A"
And issue 2 has message "ExceptionB: error B"
# A traceback block flushed before the exception line is reached produces
# an empty message, which the engine discards (0 issues).
Scenario: Traceback without exception line produces no issue
Given I use the Python traceback matcher
When I process the line "Traceback (most recent call last):"
And I process the line ' File "main.py", line 10, in <module>'
And I flush the engine
Then the engine emitted 0 issues
Scenario: Python exception matcher compiles from YAML
Given I use the Python exception matcher
Then compilation succeeds
And the result contains matcher with id "python.exception"
And the matcher "python.exception" has priority 50
Scenario: Standalone exception without traceback header
Given I use the Python exception matcher
When I process the line "ValueError: invalid literal"
And I flush the engine
Then the engine emitted 1 issue
And the issue message is "ValueError: invalid literal"
And the issue has no file