/
Str1ke
/
TheProject
Обзор
Документация
Войти
/
Str1ke
/
TheProject
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
tests/test_visualizer.py
68 строк
2 KB
AlekseyF7
Initial commit: Student Performance Analyzer project
26 дек 2025, 13:51
26 дек 2025, 13:51
84047cc
Код
Авторство
О чём код?
""" Тесты для модуля visualizer """ import pytest import os import tempfile import pandas as pd from src.visualizer import PerformanceVisualizer class TestPerformanceVisualizer: """Тесты для класса PerformanceVisualizer""" def test_plot_student_scores_distribution(self): """Тест создания графика распределения оценок""" with tempfile.TemporaryDirectory() as tmpdir: visualizer = PerformanceVisualizer(output_dir=tmpdir) data = pd.DataFrame({ 'score': [3.0, 4.0, 5.0, 3.5, 4.5] * 10 }) filepath = visualizer.plot_student_scores_distribution(data) assert os.path.exists(filepath) assert filepath.endswith('.png') def test_plot_subject_comparison(self): """Тест создания графика сравнения предметов""" with tempfile.TemporaryDirectory() as tmpdir: visualizer = PerformanceVisualizer(output_dir=tmpdir) subject_stats = pd.DataFrame({ 'subject': ['Математика', 'Физика', 'Программирование'], 'average_score': [4.0, 3.5, 4.5] }) filepath = visualizer.plot_subject_comparison(subject_stats) assert os.path.exists(filepath) assert filepath.endswith('.png') def test_create_summary_report(self): """Тест создания текстового отчета""" with tempfile.TemporaryDirectory() as tmpdir: visualizer = PerformanceVisualizer(output_dir=tmpdir) overall_stats = { 'total_students': 10, 'total_subjects': 4, 'overall_average': 3.8 } subject_stats = pd.DataFrame({ 'subject': ['Математика'], 'average_score': [4.0], 'students_count': [10] }) at_risk = [] report_path = visualizer.create_summary_report( overall_stats, subject_stats, at_risk ) assert os.path.exists(report_path) assert report_path.endswith('.txt') with open(report_path, 'r', encoding='utf-8') as f: content = f.read() assert 'ОТЧЕТ ПО УСПЕВАЕМОСТИ' in content assert '10' in content