Skip to content

Commit bf47e89

Browse files
test(presets): silence expected UserWarnings in self-test composition… (#2373)
* 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.
1 parent 81f772c commit bf47e89

1 file changed

Lines changed: 16 additions & 2 deletions

File tree

tests/test_presets.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1949,7 +1949,16 @@ def install_self_test_preset(manager: PresetManager, speckit_version: str = "0.1
19491949

19501950

19511951
class TestSelfTestPreset:
1952-
"""Tests using the self-test preset that ships with the repo."""
1952+
"""Tests using the self-test preset that ships with the repo.
1953+
1954+
The self-test preset ships a wrap-strategy command (``speckit.wrap-test``)
1955+
without a corresponding core base layer; reconciliation deliberately
1956+
surfaces a UserWarning in that case. Tests install via
1957+
``install_self_test_preset`` (defined above), which scopes a narrow
1958+
``warnings.filterwarnings`` block to that specific message and
1959+
``UserWarning`` category — so the expected warning stays quiet without
1960+
masking unrelated warnings or real reconciliation failures.
1961+
"""
19531962

19541963
def test_self_test_preset_exists(self):
19551964
"""Verify the self-test preset directory and manifest exist."""
@@ -2237,7 +2246,12 @@ def test_load_returns_empty_on_invalid_json(self, project_dir):
22372246

22382247

22392248
class TestPresetSkills:
2240-
"""Tests for preset skill registration and unregistration."""
2249+
"""Tests for preset skill registration and unregistration.
2250+
2251+
Tests that install the self-test preset use ``install_self_test_preset``
2252+
which scopes a narrow filter to the expected wrap-strategy warning.
2253+
Reconciliation failures remain audible so real regressions surface.
2254+
"""
22412255

22422256
def _write_init_options(self, project_dir, ai="claude", ai_skills=True, script="sh"):
22432257
from specify_cli import save_init_options

0 commit comments

Comments
 (0)