From 4ebcaf52f887fdfa0115c156748473cd6f246ac9 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 5 May 2026 01:31:36 +0000 Subject: [PATCH 1/6] Initial plan From b3cd3e4a675e9942ca2781a9807ec2c954d32645 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 5 May 2026 01:33:20 +0000 Subject: [PATCH 2/6] fix: avoid matplotlib backend override on import Agent-Logs-Url: https://github.com/JS2IIU-MH/adiftools-dev/sessions/16d535a8-1297-4bbf-8e18-ebb0929af222 Co-authored-by: JS2IIU-MH <146515386+JS2IIU-MH@users.noreply.github.com> --- adiftools/adifgraph.py | 3 --- tests/test_adifgraph.py | 18 ++++++++++++++++++ 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/adiftools/adifgraph.py b/adiftools/adifgraph.py index 47b72a3..efb55f4 100644 --- a/adiftools/adifgraph.py +++ b/adiftools/adifgraph.py @@ -1,4 +1,3 @@ -import matplotlib import matplotlib.pyplot as plt import pandas as pd @@ -7,8 +6,6 @@ except ModuleNotFoundError or ImportError: from errors import AdifParserError -matplotlib.use('Agg') - def monthly_qso(df, fname): ''' plot monthly QSO ''' diff --git a/tests/test_adifgraph.py b/tests/test_adifgraph.py index 028ba7c..7e83f66 100644 --- a/tests/test_adifgraph.py +++ b/tests/test_adifgraph.py @@ -1,3 +1,7 @@ +import importlib + +import matplotlib + from adiftools import adiftools from adiftools import adifgraph @@ -18,3 +22,17 @@ def test_band_percentage(): def test_monthly_band_qso(): adifgraph.monthly_band_qso(df, 'tests/monthly_band_qso.png') assert True + + +def test_import_does_not_force_matplotlib_backend(monkeypatch): + calls = [] + original_use = matplotlib.use + + def spy_use(*args, **kwargs): + calls.append((args, kwargs)) + return original_use(*args, **kwargs) + + monkeypatch.setattr(matplotlib, 'use', spy_use) + importlib.reload(adifgraph) + + assert calls == [] From 5c693342d3e0838cbadbf5c002102e9bb1be9338 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 5 May 2026 01:34:03 +0000 Subject: [PATCH 3/6] test: avoid backend side effects in matplotlib use spy Agent-Logs-Url: https://github.com/JS2IIU-MH/adiftools-dev/sessions/16d535a8-1297-4bbf-8e18-ebb0929af222 Co-authored-by: JS2IIU-MH <146515386+JS2IIU-MH@users.noreply.github.com> --- tests/test_adifgraph.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/test_adifgraph.py b/tests/test_adifgraph.py index 7e83f66..1f0bdf9 100644 --- a/tests/test_adifgraph.py +++ b/tests/test_adifgraph.py @@ -26,11 +26,10 @@ def test_monthly_band_qso(): def test_import_does_not_force_matplotlib_backend(monkeypatch): calls = [] - original_use = matplotlib.use def spy_use(*args, **kwargs): calls.append((args, kwargs)) - return original_use(*args, **kwargs) + return None monkeypatch.setattr(matplotlib, 'use', spy_use) importlib.reload(adifgraph) From 3203ddd0c3e7ac17509614d9a59036d27f4a7df6 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 5 May 2026 01:34:37 +0000 Subject: [PATCH 4/6] test: clean up backend spy helper Agent-Logs-Url: https://github.com/JS2IIU-MH/adiftools-dev/sessions/16d535a8-1297-4bbf-8e18-ebb0929af222 Co-authored-by: JS2IIU-MH <146515386+JS2IIU-MH@users.noreply.github.com> --- tests/test_adifgraph.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/test_adifgraph.py b/tests/test_adifgraph.py index 1f0bdf9..bc3d6ff 100644 --- a/tests/test_adifgraph.py +++ b/tests/test_adifgraph.py @@ -29,7 +29,6 @@ def test_import_does_not_force_matplotlib_backend(monkeypatch): def spy_use(*args, **kwargs): calls.append((args, kwargs)) - return None monkeypatch.setattr(matplotlib, 'use', spy_use) importlib.reload(adifgraph) From 9fe6a2adc68063d7af95f61fcb595f99c2593889 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 5 May 2026 01:35:12 +0000 Subject: [PATCH 5/6] test: restore adifgraph module state after reload assertion Agent-Logs-Url: https://github.com/JS2IIU-MH/adiftools-dev/sessions/16d535a8-1297-4bbf-8e18-ebb0929af222 Co-authored-by: JS2IIU-MH <146515386+JS2IIU-MH@users.noreply.github.com> --- tests/test_adifgraph.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/test_adifgraph.py b/tests/test_adifgraph.py index bc3d6ff..52dba78 100644 --- a/tests/test_adifgraph.py +++ b/tests/test_adifgraph.py @@ -34,3 +34,6 @@ def spy_use(*args, **kwargs): importlib.reload(adifgraph) assert calls == [] + + monkeypatch.undo() + importlib.reload(adifgraph) From 761e0f46fbe9792253164d94bf3548f758a5c858 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 5 May 2026 01:35:46 +0000 Subject: [PATCH 6/6] test: remove unnecessary monkeypatch cleanup lines Agent-Logs-Url: https://github.com/JS2IIU-MH/adiftools-dev/sessions/16d535a8-1297-4bbf-8e18-ebb0929af222 Co-authored-by: JS2IIU-MH <146515386+JS2IIU-MH@users.noreply.github.com> --- tests/test_adifgraph.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/tests/test_adifgraph.py b/tests/test_adifgraph.py index 52dba78..bc3d6ff 100644 --- a/tests/test_adifgraph.py +++ b/tests/test_adifgraph.py @@ -34,6 +34,3 @@ def spy_use(*args, **kwargs): importlib.reload(adifgraph) assert calls == [] - - monkeypatch.undo() - importlib.reload(adifgraph)