Skip to content

Commit d1d52cf

Browse files
Add architecture guard for sync/async example parity
Co-authored-by: Shri Sukhani <shrisukhani@users.noreply.github.com>
1 parent 39a21b1 commit d1d52cf

File tree

3 files changed

+26
-1
lines changed

3 files changed

+26
-1
lines changed

CONTRIBUTING.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,8 @@ This runs lint, format checks, compile checks, tests, and package build.
9494
- `tests/test_core_type_helper_usage.py` (core transport/config/header/file/polling/session/error/parsing manager+tool module enforcement of shared plain-type helper usage),
9595
- `tests/test_contributing_architecture_guard_listing.py` (`CONTRIBUTING.md` architecture-guard inventory completeness enforcement),
9696
- `tests/test_examples_syntax.py` (example script syntax guardrail),
97-
- `tests/test_docs_python3_commands.py` (`README`/`CONTRIBUTING`/examples python3 command consistency enforcement).
97+
- `tests/test_docs_python3_commands.py` (`README`/`CONTRIBUTING`/examples python3 command consistency enforcement),
98+
- `tests/test_example_sync_async_parity.py` (sync/async example parity enforcement).
9899

99100
## Code quality conventions
100101

tests/test_architecture_marker_usage.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
"tests/test_contributing_architecture_guard_listing.py",
2525
"tests/test_examples_syntax.py",
2626
"tests/test_docs_python3_commands.py",
27+
"tests/test_example_sync_async_parity.py",
2728
)
2829

2930

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
from pathlib import Path
2+
3+
import pytest
4+
5+
pytestmark = pytest.mark.architecture
6+
7+
8+
def test_examples_have_sync_async_parity_by_prefix():
9+
example_names = {path.stem for path in Path("examples").glob("*.py")}
10+
11+
sync_examples = {name for name in example_names if name.startswith("sync_")}
12+
async_examples = {name for name in example_names if name.startswith("async_")}
13+
14+
assert sync_examples != []
15+
assert async_examples != []
16+
17+
for sync_name in sync_examples:
18+
expected_async = sync_name.replace("sync_", "async_", 1)
19+
assert expected_async in example_names
20+
21+
for async_name in async_examples:
22+
expected_sync = async_name.replace("async_", "sync_", 1)
23+
assert expected_sync in example_names

0 commit comments

Comments
 (0)