Skip to content

Commit b2ba6b0

Browse files
committed
fix(ci): Add missing pytest markers and fix protocol tests
- Add pytest markers configuration to pyproject.toml - Add tests/conftest.py for automatic test marking - Remove redundant __runtime_checkable__ assignment - Fix protocol tests to check functionality not internals
1 parent 7751a99 commit b2ba6b0

File tree

4 files changed

+38
-7
lines changed

4 files changed

+38
-7
lines changed

pyproject.toml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,14 @@ addopts = "-ra -q"
101101
testpaths = [
102102
"tests",
103103
]
104+
markers = [
105+
"unit: Unit tests for individual components",
106+
"integration: Integration tests for component interactions",
107+
"parser: Tests for parser system components",
108+
"executor: Tests for execution/subprocess components",
109+
"design: Tests for design system components",
110+
"slow: Tests that take significant time to run",
111+
]
104112

105113
[dependency-groups]
106114
dev = [

src/cli_patterns/ui/parser/protocols.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,3 @@ def get_suggestions(self, partial: str) -> list[str]:
5454
List of suggested completions for the partial input
5555
"""
5656
...
57-
58-
59-
# Explicitly set the runtime checkable attribute for older Python versions
60-
Parser.__runtime_checkable__ = True

tests/conftest.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
"""Pytest configuration for CLI Patterns tests."""
2+
3+
import pytest
4+
5+
6+
def pytest_collection_modifyitems(config, items):
7+
"""Automatically add markers based on test file location."""
8+
for item in items:
9+
# Add unit/integration markers based on path
10+
if "tests/unit" in str(item.fspath):
11+
item.add_marker(pytest.mark.unit)
12+
elif "tests/integration" in str(item.fspath):
13+
item.add_marker(pytest.mark.integration)
14+
15+
# Add component markers based on path
16+
if "parser" in str(item.fspath):
17+
item.add_marker(pytest.mark.parser)
18+
elif "executor" in str(item.fspath) or "execution" in str(item.fspath):
19+
item.add_marker(pytest.mark.executor)
20+
elif "design" in str(item.fspath):
21+
item.add_marker(pytest.mark.design)

tests/unit/ui/parser/test_protocols.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,11 @@ class TestParserProtocol:
1616

1717
def test_parser_is_runtime_checkable(self) -> None:
1818
"""Test that Parser protocol is runtime checkable."""
19-
assert hasattr(Parser, "__runtime_checkable__")
19+
# Check that we can use isinstance with the protocol
20+
# Parser should be decorated with @runtime_checkable
21+
# which makes it usable with isinstance
22+
mock_parser = Mock(spec=Parser)
23+
assert isinstance(mock_parser, Parser)
2024

2125
def test_parser_protocol_methods(self) -> None:
2226
"""Test that Parser protocol has required methods."""
@@ -451,8 +455,10 @@ def test_protocol_typing_information(self) -> None:
451455
# Should be identifiable as a Protocol
452456
assert issubclass(Parser, Protocol)
453457

454-
# Should have runtime checkable decorator
455-
assert getattr(Parser, "__runtime_checkable__", False)
458+
# Should be runtime checkable (can use isinstance)
459+
# The @runtime_checkable decorator enables this
460+
mock_obj = Mock(spec=Parser)
461+
assert isinstance(mock_obj, Parser), "Parser should be runtime checkable"
456462

457463

458464
class TestParserProtocolEdgeCases:

0 commit comments

Comments
 (0)