Files
python_parser/run_tests.py
2025-09-04 18:56:36 +03:00

34 lines
988 B
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env python3
"""
Скрипт для запуска тестов парсеров
"""
import subprocess
import sys
import os
def run_tests():
"""Запуск тестов"""
print(" Запуск тестов парсеров...")
print("=" * 50)
# Переходим в директорию проекта
os.chdir(os.path.dirname(os.path.abspath(__file__)))
# Запускаем pytest
cmd = [sys.executable, "-m", "pytest", "tests/", "-v", "--tb=short"]
try:
result = subprocess.run(cmd, check=True, capture_output=True, text=True)
print(result.stdout)
print(" Все тесты прошли успешно!")
return True
except subprocess.CalledProcessError as e:
print(" Некоторые тесты не прошли:")
print(e.stdout)
print(e.stderr)
return False
if __name__ == "__main__":
success = run_tests()
sys.exit(0 if success else 1)