From 1bfb7dcc208ad410793e9d77a000e602071add11 Mon Sep 17 00:00:00 2001 From: Alexander Myasoedov Date: Wed, 3 Jun 2026 14:59:43 +0300 Subject: [PATCH] fix(use_agg_backend): --- agentic_security/report_chart.py | 1 - tests/unit/test_report_chart.py | 13 ++++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/agentic_security/report_chart.py b/agentic_security/report_chart.py index 3197228..930841c 100644 --- a/agentic_security/report_chart.py +++ b/agentic_security/report_chart.py @@ -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.") diff --git a/tests/unit/test_report_chart.py b/tests/unit/test_report_chart.py index f0a3a29..4cd3493 100644 --- a/tests/unit/test_report_chart.py +++ b/tests/unit/test_report_chart.py @@ -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([])