Files
ivatar/scripts/run_tests_with_coverage.py
Oliver Falk eeeb8a4f3a Simplify test scripts and move run_tests_local.sh to scripts/
- Move run_tests_local.sh to scripts/ directory for consistency
- Remove explicit test module listing from all test scripts
- Let Django auto-discover all tests instead of maintaining explicit lists
- Update README.md to reference new script location
- Simplify scripts/run_tests_with_coverage.py to use auto-discovery
- Reduce maintenance burden by eliminating duplicate test module lists
2025-10-16 18:00:17 +02:00

35 lines
1.0 KiB
Python
Executable File

#!/usr/bin/env python3
"""
Run tests with OpenTelemetry enabled and coverage measurement.
This script is designed to be used with 'coverage run' command.
"""
import os
import subprocess
import sys
def main():
# Enable OpenTelemetry
os.environ['ENABLE_OPENTELEMETRY'] = 'true'
os.environ['OTEL_ENABLED'] = 'true'
os.environ['OTEL_SERVICE_NAME'] = 'ivatar-test'
os.environ['OTEL_ENVIRONMENT'] = 'test'
print("Running tests with OpenTelemetry enabled...")
print("==========================================")
# Run Django tests (Django will auto-discover all tests)
cmd = ['python3', 'manage.py', 'test', '-v2']
try:
result = subprocess.run(cmd, check=True)
print("")
print("Tests completed successfully (OpenTelemetry enabled)")
return result.returncode
except subprocess.CalledProcessError as e:
print(f"Tests failed with exit code {e.returncode}")
return e.returncode
if __name__ == '__main__':
sys.exit(main())