pytests
This commit is contained in:
33
run_tests.py
Normal file
33
run_tests.py
Normal file
@@ -0,0 +1,33 @@
|
||||
#!/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)
|
||||
Reference in New Issue
Block a user