fix(use_agg_backend):

This commit is contained in:
Alexander Myasoedov
2026-06-03 14:59:43 +03:00
parent c0322d1130
commit 1bfb7dcc20
2 changed files with 10 additions and 4 deletions
-1
View File
@@ -59,7 +59,6 @@ def _plot_security_report(table: Table) -> io.BytesIO:
Returns:
io.BytesIO: A buffer containing the generated plot image in PNG format.
"""
return io.BytesIO()
# Data preprocessing
logger.info("Data preprocessing started.")
+10 -3
View File
@@ -2,8 +2,7 @@ import io
import matplotlib
import pytest
matplotlib.use("Agg")
from inline_snapshot import snapshot
from agentic_security.report_chart import (
_generate_identifiers,
@@ -12,6 +11,11 @@ from agentic_security.report_chart import (
)
@pytest.fixture(autouse=True)
def use_agg_backend():
matplotlib.use("Agg")
class TestGenerateIdentifiers:
def test_single_row(self):
data = type("DF", (), {"__len__": lambda s: 1})()
@@ -58,7 +62,10 @@ class TestPlotSecurityReport:
{"module": "mod_c", "failureRate": 25.0, "tokens": 500},
]
result = plot_security_report(table_data)
assert result.getvalue() != b""
# A real plot was rendered: non-empty buffer carrying the PNG signature.
png = result.getvalue()
assert len(png) > 0
assert png[:8] == snapshot(b"\x89PNG\r\n\x1a\n")
def test_handles_empty_data(self):
result = plot_security_report([])