From 57b1454eb8807e29ee3dc9b41f4e94a618d5f4aa Mon Sep 17 00:00:00 2001 From: Baixiaochun <182930459+Bingtagui404@users.noreply.github.com> Date: Fri, 20 Mar 2026 20:20:03 +0800 Subject: [PATCH] fix(tests): stabilize test_ignored_keywords across CI Remove the skip marker and replace brittle warning-count assertions with specific message-content checks. Filter only UltraPlotWarning instances and verify the expected keyword names appear in the warning messages, making the test resilient to unrelated warnings from different environments. closes #641 --- ultraplot/tests/test_format.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/ultraplot/tests/test_format.py b/ultraplot/tests/test_format.py index 72eb83d1a..f1d7343c2 100644 --- a/ultraplot/tests/test_format.py +++ b/ultraplot/tests/test_format.py @@ -16,23 +16,30 @@ # assert uplt.rc["image.cmap"] == uplt.rc["cmap.sequential"] == "_magma_copy_r" -@pytest.mark.skip(reason="This is failing on github but not locally") def test_ignored_keywords(): """ Test ignored keywords and functions. """ with warnings.catch_warnings(record=True) as record: + warnings.simplefilter("always") fig, ax = uplt.subplots( gridspec_kw={"left": 3}, subplot_kw={"proj": "cart"}, subplotpars={"left": 0.2}, ) - # only capture ultraplot warnings not general mpl warnings, e.g. deprecation warnings - record = [r for r in record if "UltraPlotWarning" in str(r)] - assert len(record) == 3 + # Filter to only UltraPlotWarning to avoid environment-specific noise + uplt_warnings = [r for r in record if issubclass(r.category, uplt.warnings.UltraPlotWarning)] + messages = [str(w.message) for w in uplt_warnings] + assert any("gridspec_kw" in m for m in messages), f"Expected gridspec_kw warning, got: {messages}" + assert any("subplot_kw" in m for m in messages), f"Expected subplot_kw warning, got: {messages}" + assert any("subplotpars" in m for m in messages), f"Expected subplotpars warning, got: {messages}" + with warnings.catch_warnings(record=True) as record: + warnings.simplefilter("always") fig.subplots_adjust(left=0.2) - assert len(record) == 1 + uplt_warnings = [r for r in record if issubclass(r.category, uplt.warnings.UltraPlotWarning)] + messages = [str(w.message) for w in uplt_warnings] + assert any("subplots_adjust" in m for m in messages), f"Expected subplots_adjust warning, got: {messages}" @pytest.mark.mpl_image_compare