Skip to content

Commit 6a19f38

Browse files
committed
notes: Update notes
1 parent 3c55281 commit 6a19f38

File tree

1 file changed

+43
-24
lines changed

1 file changed

+43
-24
lines changed

notes/proposals/03-testing-system.md

+43-24
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Testing System Proposal
22

3-
> Enhancing the testing infrastructure to improve maintainability, coverage, and developer experience.
3+
> Enhancing the testing infrastructure to improve maintainability, coverage, and developer experience using argparse with Python 3.9+ typing and shtab support.
44
55
## Current Issues
66

@@ -64,6 +64,7 @@ The audit identified several issues with the current testing system:
6464
1. **Centralized Fixtures**:
6565
```python
6666
# tests/conftest.py
67+
import typing as t
6768
import pytest
6869
from pathlib import Path
6970
import tempfile
@@ -74,7 +75,7 @@ The audit identified several issues with the current testing system:
7475
"""Create a temporary directory for testing.
7576
7677
Returns
77-
-------
78+
----
7879
Path
7980
Path to temporary directory
8081
"""
@@ -86,12 +87,12 @@ The audit identified several issues with the current testing system:
8687
"""Create a sample configuration file.
8788
8889
Parameters
89-
----------
90+
----
9091
temp_dir : Path
9192
Temporary directory fixture
9293
9394
Returns
94-
-------
95+
----
9596
Path
9697
Path to sample configuration file
9798
"""
@@ -111,6 +112,7 @@ The audit identified several issues with the current testing system:
111112
2. **Factory Fixtures**:
112113
```python
113114
# tests/conftest.py
115+
import typing as t
114116
import pytest
115117
from vcspull.config.models import Repository, VCSPullConfig
116118
from pathlib import Path
@@ -120,7 +122,7 @@ The audit identified several issues with the current testing system:
120122
"""Factory fixture to create Repository instances.
121123
122124
Returns
123-
-------
125+
----
124126
Callable
125127
Function to create repositories
126128
"""
@@ -137,7 +139,7 @@ The audit identified several issues with the current testing system:
137139
"""Factory fixture to create VCSPullConfig instances.
138140
139141
Returns
140-
-------
142+
----
141143
Callable
142144
Function to create configurations
143145
"""
@@ -156,6 +158,7 @@ The audit identified several issues with the current testing system:
156158
1. **Isolated Filesystem Operations**:
157159
```python
158160
# tests/unit/vcspull/config/test_loader.py
161+
import typing as t
159162
import pytest
160163
from pathlib import Path
161164

@@ -165,7 +168,7 @@ The audit identified several issues with the current testing system:
165168
"""Test loading configuration from a file.
166169
167170
Parameters
168-
----------
171+
----
169172
temp_dir : Path
170173
Temporary directory fixture
171174
"""
@@ -186,6 +189,7 @@ The audit identified several issues with the current testing system:
186189
2. **Environment Variable Isolation**:
187190
```python
188191
# tests/unit/vcspull/config/test_loader.py
192+
import typing as t
189193
import pytest
190194
import os
191195

@@ -195,7 +199,7 @@ The audit identified several issues with the current testing system:
195199
"""Test loading configuration from environment variables.
196200
197201
Parameters
198-
----------
202+
----
199203
monkeypatch : pytest.MonkeyPatch
200204
Pytest monkeypatch fixture
201205
temp_dir : Path
@@ -227,6 +231,7 @@ The audit identified several issues with the current testing system:
227231
1. **Configuration Data Generators**:
228232
```python
229233
# tests/strategies.py
234+
import typing as t
230235
from hypothesis import strategies as st
231236
from pathlib import Path
232237

@@ -261,6 +266,7 @@ The audit identified several issues with the current testing system:
261266
2. **Testing Invariants**:
262267
```python
263268
# tests/unit/vcspull/config/test_validation.py
269+
import typing as t
264270
import pytest
265271
from hypothesis import given, strategies as st
266272

@@ -272,7 +278,7 @@ The audit identified several issues with the current testing system:
272278
"""Test that config serialization and deserialization preserves data.
273279
274280
Parameters
275-
----------
281+
----
276282
config_data : dict
277283
Generated configuration data
278284
"""
@@ -304,22 +310,25 @@ The audit identified several issues with the current testing system:
304310
1. **Doctests for Key Functions**:
305311
```python
306312
# src/vcspull/config/__init__.py
307-
def load_config(config_path: Optional[Path] = None) -> VCSPullConfig:
313+
import typing as t
314+
from pathlib import Path
315+
316+
def load_config(config_path: t.Optional[Path] = None) -> VCSPullConfig:
308317
"""Load configuration from file.
309318
310319
Parameters
311-
----------
320+
----
312321
config_path : Optional[Path]
313322
Path to configuration file, defaults to environment variable
314323
VCSPULL_CONFIG or standard locations
315324
316325
Returns
317-
-------
326+
----
318327
VCSPullConfig
319328
Loaded configuration
320329
321330
Examples
322-
--------
331+
----
323332
>>> from pathlib import Path
324333
>>> from tempfile import NamedTemporaryFile
325334
>>> with NamedTemporaryFile(mode='w', suffix='.yaml') as f:
@@ -342,6 +351,7 @@ The audit identified several issues with the current testing system:
342351
2. **Example-Based Tests**:
343352
```python
344353
# tests/examples/config/test_basic_usage.py
354+
import typing as t
345355
import pytest
346356
from pathlib import Path
347357

@@ -352,7 +362,7 @@ The audit identified several issues with the current testing system:
352362
"""Test basic configuration usage example.
353363
354364
Parameters
355-
----------
365+
----
356366
temp_dir : Path
357367
Temporary directory fixture
358368
"""
@@ -389,6 +399,7 @@ The audit identified several issues with the current testing system:
389399
1. **CLI Command Tests**:
390400
```python
391401
# tests/functional/test_cli_commands.py
402+
import typing as t
392403
import pytest
393404
import argparse
394405
from pathlib import Path
@@ -402,7 +413,7 @@ The audit identified several issues with the current testing system:
402413
"""Test sync command.
403414
404415
Parameters
405-
----------
416+
----
406417
temp_dir : Path
407418
Temporary directory fixture
408419
monkeypatch : pytest.MonkeyPatch
@@ -440,6 +451,7 @@ The audit identified several issues with the current testing system:
440451
2. **Argparse Testing with Python 3.9+ Typing**:
441452
```python
442453
# tests/unit/vcspull/cli/test_argparse.py
454+
import typing as t
443455
import pytest
444456
import argparse
445457
from pathlib import Path
@@ -472,6 +484,7 @@ The audit identified several issues with the current testing system:
472484
3. **Shell Completion Testing**:
473485
```python
474486
# tests/unit/vcspull/cli/test_completion.py
487+
import typing as t
475488
import pytest
476489
import argparse
477490
import sys
@@ -482,7 +495,7 @@ The audit identified several issues with the current testing system:
482495
"""Test shell completion generation.
483496
484497
Parameters
485-
----------
498+
----
486499
monkeypatch : pytest.MonkeyPatch
487500
Pytest monkeypatch fixture
488501
"""
@@ -516,6 +529,7 @@ The audit identified several issues with the current testing system:
516529
4. **Mock CLI Environment**:
517530
```python
518531
# tests/unit/vcspull/cli/test_cli_context.py
532+
import typing as t
519533
import pytest
520534
import io
521535
import sys
@@ -526,7 +540,7 @@ The audit identified several issues with the current testing system:
526540
"""Test CliContext output formatting.
527541
528542
Parameters
529-
----------
543+
----
530544
monkeypatch : pytest.MonkeyPatch
531545
Pytest monkeypatch fixture
532546
"""
@@ -558,6 +572,7 @@ The audit identified several issues with the current testing system:
558572
5. **CLI Output Format Tests**:
559573
```python
560574
# tests/functional/test_cli_output.py
575+
import typing as t
561576
import pytest
562577
import json
563578
import yaml
@@ -570,7 +585,7 @@ The audit identified several issues with the current testing system:
570585
"""Test detect command JSON output.
571586
572587
Parameters
573-
----------
588+
----
574589
temp_dir : Path
575590
Temporary directory fixture
576591
monkeypatch : pytest.MonkeyPatch
@@ -612,6 +627,7 @@ The audit identified several issues with the current testing system:
612627
1. **VCS Command Mocking**:
613628
```python
614629
# tests/unit/vcspull/vcs/test_git.py
630+
import typing as t
615631
import pytest
616632
import subprocess
617633
from unittest.mock import patch, Mock
@@ -623,7 +639,7 @@ The audit identified several issues with the current testing system:
623639
"""Test Git clone operation with mocked subprocess.
624640
625641
Parameters
626-
----------
642+
----
627643
monkeypatch : pytest.MonkeyPatch
628644
Pytest monkeypatch fixture
629645
"""
@@ -655,6 +671,7 @@ The audit identified several issues with the current testing system:
655671
2. **Network Service Mocks**:
656672
```python
657673
# tests/integration/test_sync_operations.py
674+
import typing as t
658675
import pytest
659676
import responses
660677
from pathlib import Path
@@ -669,12 +686,12 @@ The audit identified several issues with the current testing system:
669686
"""Mock Git commands.
670687
671688
Parameters
672-
----------
689+
----
673690
monkeypatch : pytest.MonkeyPatch
674691
Pytest monkeypatch fixture
675692
676693
Returns
677-
-------
694+
----
678695
Mock
679696
Mock for subprocess.run
680697
"""
@@ -690,7 +707,7 @@ The audit identified several issues with the current testing system:
690707
"""Test sync operations with mocked network and Git commands.
691708
692709
Parameters
693-
----------
710+
----
694711
temp_dir : Path
695712
Temporary directory fixture
696713
mock_git_commands : Mock
@@ -740,13 +757,14 @@ The audit identified several issues with the current testing system:
740757
2. **Custom Markers**:
741758
```python
742759
# tests/conftest.py
760+
import typing as t
743761
import pytest
744762

745763
def pytest_configure(config):
746764
"""Configure pytest.
747765
748766
Parameters
749-
----------
767+
----
750768
config : pytest.Config
751769
Pytest configuration object
752770
"""
@@ -764,7 +782,7 @@ The audit identified several issues with the current testing system:
764782
"""Set up test run.
765783
766784
Parameters
767-
----------
785+
----
768786
item : pytest.Item
769787
Test item
770788
"""
@@ -779,6 +797,7 @@ The audit identified several issues with the current testing system:
779797
3. **Integration with Development Loop**:
780798
```python
781799
# scripts/test.py
800+
import typing as t
782801
import argparse
783802
import subprocess
784803
import sys

0 commit comments

Comments
 (0)