/
liquid-g
/
liquid-code
Обзор
Документация
Войти
/
liquid-g
/
liquid-code
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
develop-0.4
analyze_coverage.py
65 строк
2 KB
User
0.4.9 - переработка документации, рефакторинг кода, покрытие тестами 70%
06 июл 2026, 13:37
06 июл 2026, 13:37
79b2ebc
Код
Авторство
О чём код?
#!/usr/bin/env python """ Анализ покрытия тестами кода. Читает coverage.json и выводит отчет по модулям. """ import json import os import sys def main(): if not os.path.exists('coverage.json'): print("coverage.json not found. Run tests with coverage first:") print(" python -m pytest tests/ --cov=src --cov-report=json") sys.exit(1) with open('coverage.json', 'r', encoding='utf-8') as f: data = json.load(f) files = data.get('files', {}) print("=== Modules with 80%+ coverage ===") covered_80 = [ (f.replace('\\', '/'), info['summary']['percent_covered']) for f, info in files.items() if info['summary']['percent_covered'] >= 80 ] for path, cover in sorted(covered_80, key=lambda x: -x[1]): print(f'{path}: {cover:.1f}%') print("\n=== Modules with 60-79% coverage ===") covered_60 = [ (f.replace('\\', '/'), info['summary']['percent_covered']) for f, info in files.items() if 60 <= info['summary']['percent_covered'] < 80 ] for path, cover in sorted(covered_60, key=lambda x: -x[1]): print(f'{path}: {cover:.1f}%') print("\n=== Modules with <60% coverage (priority for tests) ===") covered_low = [ (f.replace('\\', '/'), info['summary']['percent_covered']) for f, info in files.items() if info['summary']['percent_covered'] < 60 ] for path, cover in sorted(covered_low, key=lambda x: x[1]): print(f'{path}: {cover:.1f}%') print("\n=== Modules with 0% coverage ===") zero = [ (f.replace('\\', '/'), info['summary']['percent_covered']) for f, info in files.items() if info['summary']['percent_covered'] == 0 ] for path, cover in sorted(zero, key=lambda x: x[1]): print(f'{path}: {cover:.1f}%') total_covered = sum(info['summary']['covered_lines'] for info in files.values()) total_statements = sum(info['summary']['num_statements'] for info in files.values()) print(f"\n=== TOTAL: {total_covered}/{total_statements} = {total_covered/total_statements*100:.1f}% ===") if __name__ == '__main__': main()