mirror of
https://github.com/usestrix/strix.git
synced 2026-08-20 02:23:35 +02:00
fix(reports): auto-detect PoC language with Python fallback
This commit is contained in:
@@ -2,7 +2,13 @@
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from strix.interface.tui.renderers.fenced import parse_fenced_code
|
||||
from pygments.lexers import BashLexer, PythonLexer
|
||||
|
||||
from strix.interface.tui.renderers.fenced import (
|
||||
guess_language_name,
|
||||
parse_fenced_code,
|
||||
resolve_lexer,
|
||||
)
|
||||
from strix.viewer.report_pdf import _strip_code_fence
|
||||
|
||||
|
||||
@@ -43,3 +49,16 @@ def test_strip_code_fence_removes_fence() -> None:
|
||||
def test_strip_code_fence_passes_through_non_string_and_unfenced() -> None:
|
||||
assert _strip_code_fence(None) is None
|
||||
assert _strip_code_fence("x = 1") == "x = 1"
|
||||
|
||||
|
||||
def test_resolve_lexer_honors_explicit_language() -> None:
|
||||
assert isinstance(resolve_lexer("bash", "echo hi"), BashLexer)
|
||||
|
||||
|
||||
def test_resolve_lexer_falls_back_to_python_when_unresolvable() -> None:
|
||||
# Unknown language name and empty body -> nothing to auto-detect -> Python.
|
||||
assert isinstance(resolve_lexer("not-a-language", ""), PythonLexer)
|
||||
|
||||
|
||||
def test_guess_language_name_defaults_to_python_when_inconclusive() -> None:
|
||||
assert guess_language_name("") == "python"
|
||||
|
||||
Reference in New Issue
Block a user