style: 代码格式化

This commit is contained in:
2025-12-13 21:47:37 +08:00
parent a0b327cdbb
commit baa7ac8ee9
64 changed files with 755 additions and 573 deletions

View File

@@ -3,6 +3,7 @@ Test runner script for HeurAMS.
This script runs all unit tests and provides a summary report.
"""
import sys
import pytest
import os
@@ -22,10 +23,10 @@ def run_tests():
# Run tests with verbose output
test_args = [
"-v", # Verbose output
"--tb=short", # Short traceback format
"-v", # Verbose output
"--tb=short", # Short traceback format
"--color=yes", # Color output
"tests/" # Test directory
"tests/", # Test directory
]
print(f"Running tests from: {os.path.abspath('tests')}")
@@ -59,8 +60,8 @@ def run_specific_test(test_file=None, test_class=None, test_method=None):
sys.path.insert(0, src_dir)
test_args = [
"-v", # Verbose output
"--tb=short", # Short traceback format
"-v", # Verbose output
"--tb=short", # Short traceback format
"--color=yes", # Color output
]
@@ -92,6 +93,7 @@ def run_examples():
try:
from tests.examples import run_all_examples
run_all_examples()
return 0
except Exception as e:
@@ -103,31 +105,21 @@ if __name__ == "__main__":
import argparse
parser = argparse.ArgumentParser(description="HeurAMS Test Runner")
parser.add_argument("--all", action="store_true", help="Run all tests (default)")
parser.add_argument(
"--all",
action="store_true",
help="Run all tests (default)"
)
parser.add_argument(
"--file",
type=str,
help="Run specific test file (e.g., test_particles.py)"
"--file", type=str, help="Run specific test file (e.g., test_particles.py)"
)
parser.add_argument(
"--class",
dest="test_class",
type=str,
help="Run specific test class (requires --file)"
help="Run specific test class (requires --file)",
)
parser.add_argument(
"--method",
type=str,
help="Run specific test method (requires --class)"
"--method", type=str, help="Run specific test method (requires --class)"
)
parser.add_argument(
"--examples",
action="store_true",
help="Run examples instead of tests"
"--examples", action="store_true", help="Run examples instead of tests"
)
args = parser.parse_args()
@@ -136,11 +128,9 @@ if __name__ == "__main__":
exit_code = run_examples()
elif args.file:
exit_code = run_specific_test(
test_file=args.file,
test_class=args.test_class,
test_method=args.method
test_file=args.file, test_class=args.test_class, test_method=args.method
)
else:
exit_code = run_tests()
sys.exit(exit_code)
sys.exit(exit_code)