mirror of
https://github.com/josegonzalez/python-github-backup.git
synced 2026-01-14 10:02:38 +01:00
Refactor test fixtures to use shared create_args helper
Uses the real parse_args() function to get CLI defaults, so when new arguments are added they're automatically available to all tests. Changes: - Add tests/conftest.py with create_args fixture - Update 8 test files to use shared fixture - Remove duplicate _create_mock_args methods - Remove redundant @pytest.fixture mock_args definitions This eliminates the need to update multiple test files when adding new CLI arguments.
This commit is contained in:
25
tests/conftest.py
Normal file
25
tests/conftest.py
Normal file
@@ -0,0 +1,25 @@
|
||||
"""Shared pytest fixtures for github-backup tests."""
|
||||
|
||||
import pytest
|
||||
|
||||
from github_backup.github_backup import parse_args
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def create_args():
|
||||
"""Factory fixture that creates args with real CLI defaults.
|
||||
|
||||
Uses the actual argument parser so new CLI args are automatically
|
||||
available with their defaults - no test updates needed.
|
||||
|
||||
Usage:
|
||||
def test_something(self, create_args):
|
||||
args = create_args(include_releases=True, user="myuser")
|
||||
"""
|
||||
def _create(**overrides):
|
||||
# Use real parser to get actual defaults
|
||||
args = parse_args(["testuser"])
|
||||
for key, value in overrides.items():
|
||||
setattr(args, key, value)
|
||||
return args
|
||||
return _create
|
||||
Reference in New Issue
Block a user