From bf47e8924991dbd5691b75f1b3ebd04082aceba7 Mon Sep 17 00:00:00 2001 From: Quratulain-bilal Date: Tue, 12 May 2026 01:16:55 +0500 Subject: [PATCH] =?UTF-8?q?test(presets):=20silence=20expected=20UserWarni?= =?UTF-8?q?ngs=20in=20self-test=20composition=E2=80=A6=20(#2373)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * test(presets): silence expected UserWarnings in self-test composition tests The self-test preset that ships with the repo provides a wrap-strategy command (speckit.wrap-test) intentionally without a corresponding core base layer, exercising the 'no base layer' branch of _reconcile_composed_commands(). Eighteen tests across TestSelfTestPreset and TestPresetSkills install this preset and trigger an expected UserWarning. Running the suite with -W error::UserWarning surfaces them as test noise that could obscure unrelated warnings. Add class-level pytest.mark.filterwarnings filters to acknowledge the two known messages ('Cannot compose command speckit.wrap-test' and 'Post-install reconciliation failed for self-test') so other UserWarning sources still propagate normally. Fixes #2363 * test(presets): scope filterwarnings to UserWarning category Address Copilot review on #2373: the previous filterwarnings entries omitted the warning category, so any warning class with a matching message would have been silenced. Append :UserWarning to the four filters so only the deliberately-emitted UserWarnings from _reconcile_composed_commands() are ignored. * test(presets): narrow self-test warning filter to install helper only Address Copilot feedback: the class-level @pytest.mark.filterwarnings on TestPresetSkills was too broad. The 'Post-install reconciliation failed' filter could mask real reconciliation regressions, since that warning is only emitted when _reconcile_composed_commands/_reconcile_skills raises. Tests in TestPresetSkills already call install_self_test_preset(), which scopes a narrow filter to the expected wrap-strategy 'Cannot compose' warning. The class-level filters are redundant for those calls and unsafe elsewhere, so they are removed. * test(presets): align TestSelfTestPreset docstring with helper-based filtering Address Copilot feedback: docstring referred to 'filters above', but the fix uses warnings.filterwarnings inside install_self_test_preset rather than class-level decorators. Updated the docstring to describe the actual mechanism. * test(presets): remove extra blank line between helper and class (PEP 8) Address Copilot feedback: PEP 8 expects two blank lines between top-level definitions; reduce the three blank lines between install_self_test_preset and TestSelfTestPreset to two. --- tests/test_presets.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/tests/test_presets.py b/tests/test_presets.py index e5143b834..52566cbed 100644 --- a/tests/test_presets.py +++ b/tests/test_presets.py @@ -1949,7 +1949,16 @@ def install_self_test_preset(manager: PresetManager, speckit_version: str = "0.1 class TestSelfTestPreset: - """Tests using the self-test preset that ships with the repo.""" + """Tests using the self-test preset that ships with the repo. + + The self-test preset ships a wrap-strategy command (``speckit.wrap-test``) + without a corresponding core base layer; reconciliation deliberately + surfaces a UserWarning in that case. Tests install via + ``install_self_test_preset`` (defined above), which scopes a narrow + ``warnings.filterwarnings`` block to that specific message and + ``UserWarning`` category — so the expected warning stays quiet without + masking unrelated warnings or real reconciliation failures. + """ def test_self_test_preset_exists(self): """Verify the self-test preset directory and manifest exist.""" @@ -2237,7 +2246,12 @@ class TestInitOptions: class TestPresetSkills: - """Tests for preset skill registration and unregistration.""" + """Tests for preset skill registration and unregistration. + + Tests that install the self-test preset use ``install_self_test_preset`` + which scopes a narrow filter to the expected wrap-strategy warning. + Reconciliation failures remain audible so real regressions surface. + """ def _write_init_options(self, project_dir, ai="claude", ai_skills=True, script="sh"): from specify_cli import save_init_options