paper-dynasty-discord/tests/players_refactor/run_tests.py
Cal Corum ee80cd72ae fix: apply Black formatting and resolve ruff lint violations
Run Black formatter across 83 files and fix 1514 ruff violations:
- E722: bare except → typed exceptions (17 fixes)
- E711/E712/E721: comparison style fixes with noqa for SQLAlchemy (44 fixes)
- F841: unused variable assignments (70 fixes)
- F541/F401: f-string and import cleanup (1383 auto-fixes)

Remaining 925 errors are all F403/F405 (star imports) — structural,
requires converting to explicit imports in a separate effort.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 11:37:46 -05:00

105 lines
2.6 KiB
Python
Executable File

#!/usr/bin/env python3
# Test runner for players refactor modules
import sys
import os
import subprocess
import argparse
def run_tests(module=None, coverage=False, fast=False):
"""Run tests for the players refactor."""
# Base command
cmd = [sys.executable, "-m", "pytest"]
# Add test directory
test_dir = os.path.join(os.path.dirname(__file__))
cmd.append(test_dir)
# Module-specific test
if module:
test_file = f"test_{module}.py"
test_path = os.path.join(test_dir, test_file)
if os.path.exists(test_path):
cmd = [sys.executable, "-m", "pytest", test_path]
else:
print(f"Test file {test_file} not found!")
return False
# Fast tests (exclude slow/integration tests)
if fast:
cmd.extend(["-m", "not slow and not integration"])
# Coverage reporting
if coverage:
cmd.extend(
[
"--cov=cogs.players",
"--cov-report=term-missing",
"--cov-report=html:htmlcov",
]
)
# Verbose output
cmd.extend(["-v", "--tb=short"])
print(f"Running command: {' '.join(cmd)}")
try:
result = subprocess.run(cmd, cwd=os.path.dirname(os.path.dirname(__file__)))
return result.returncode == 0
except Exception as e:
print(f"Error running tests: {e}")
return False
def main():
parser = argparse.ArgumentParser(description="Run players refactor tests")
parser.add_argument(
"command",
nargs="?",
default="all",
choices=[
"all",
"fast",
"coverage",
"player_lookup",
"team_management",
"paperdex",
"standings_records",
"gauntlet",
"utility_commands",
],
help="Test command to run",
)
parser.add_argument("--module", help="Specific module to test")
args = parser.parse_args()
if args.command == "all":
success = run_tests()
elif args.command == "fast":
success = run_tests(fast=True)
elif args.command == "coverage":
success = run_tests(coverage=True)
elif args.command in [
"player_lookup",
"team_management",
"paperdex",
"standings_records",
"gauntlet",
"utility_commands",
]:
success = run_tests(module=args.command)
elif args.module:
success = run_tests(module=args.module)
else:
success = run_tests()
sys.exit(0 if success else 1)
if __name__ == "__main__":
main()