commit
6bbbdf1639
@ -0,0 +1,231 @@
|
||||
# Byte-compiled / optimized / DLL files
|
||||
__pycache__/
|
||||
*.py[cod]
|
||||
*$py.class
|
||||
|
||||
# C extensions
|
||||
*.so
|
||||
|
||||
# Distribution / packaging
|
||||
.Python
|
||||
build/
|
||||
develop-eggs/
|
||||
dist/
|
||||
downloads/
|
||||
eggs/
|
||||
.eggs/
|
||||
lib/
|
||||
lib64/
|
||||
parts/
|
||||
sdist/
|
||||
var/
|
||||
wheels/
|
||||
share/python-wheels/
|
||||
*.egg-info/
|
||||
.installed.cfg
|
||||
*.egg
|
||||
MANIFEST
|
||||
|
||||
# PyInstaller
|
||||
# Usually these files are written by a python script from a template
|
||||
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
||||
*.manifest
|
||||
*.spec
|
||||
|
||||
# Installer logs
|
||||
pip-log.txt
|
||||
pip-delete-this-directory.txt
|
||||
|
||||
# Unit test / coverage reports
|
||||
htmlcov/
|
||||
.tox/
|
||||
.nox/
|
||||
.coverage
|
||||
.coverage.*
|
||||
.cache
|
||||
nosetests.xml
|
||||
coverage.xml
|
||||
*.cover
|
||||
*.py,cover
|
||||
.hypothesis/
|
||||
.pytest_cache/
|
||||
cover/
|
||||
|
||||
# Translations
|
||||
*.mo
|
||||
*.pot
|
||||
|
||||
# Django stuff:
|
||||
*.log
|
||||
local_settings.py
|
||||
db.sqlite3
|
||||
db.sqlite3-journal
|
||||
|
||||
# Flask stuff:
|
||||
instance/
|
||||
.webassets-cache
|
||||
|
||||
# Scrapy stuff:
|
||||
.scrapy
|
||||
|
||||
# Sphinx documentation
|
||||
docs/_build/
|
||||
|
||||
# PyBuilder
|
||||
.pybuilder/
|
||||
target/
|
||||
|
||||
# Jupyter Notebook
|
||||
.ipynb_checkpoints
|
||||
|
||||
# IPython
|
||||
profile_default/
|
||||
ipython_config.py
|
||||
|
||||
# pyenv
|
||||
# For a library or package, you might want to ignore these files since the code is
|
||||
# intended to run in multiple environments; otherwise, check them in:
|
||||
.python-version
|
||||
|
||||
# pipenv
|
||||
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
||||
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
||||
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
||||
# install all needed dependencies.
|
||||
Pipfile.lock
|
||||
|
||||
# poetry
|
||||
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
||||
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
||||
# commonly ignored for libraries.
|
||||
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
||||
poetry.lock
|
||||
|
||||
# pdm
|
||||
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
||||
#pdm.lock
|
||||
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
|
||||
# in version control.
|
||||
# https://pdm.fming.dev/#use-with-ide
|
||||
.pdm.toml
|
||||
|
||||
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
||||
__pypackages__/
|
||||
|
||||
# Celery stuff
|
||||
celerybeat-schedule
|
||||
celerybeat.pid
|
||||
|
||||
# SageMath parsed files
|
||||
*.sage.py
|
||||
|
||||
# Environments
|
||||
.env
|
||||
.venv
|
||||
env/
|
||||
venv/
|
||||
ENV/
|
||||
env.bak/
|
||||
venv.bak/
|
||||
|
||||
# Spyder project settings
|
||||
.spyderproject
|
||||
.spyproject
|
||||
|
||||
# Rope project settings
|
||||
.ropeproject
|
||||
|
||||
# mkdocs documentation
|
||||
/site
|
||||
|
||||
# mypy
|
||||
.mypy_cache/
|
||||
.dmypy.json
|
||||
dmypy.json
|
||||
|
||||
# Pyre type checker
|
||||
.pyre/
|
||||
|
||||
# pytype static type analyzer
|
||||
.pytype/
|
||||
|
||||
# Cython debug symbols
|
||||
cython_debug/
|
||||
|
||||
# PyCharm
|
||||
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
||||
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
||||
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
||||
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
||||
#.idea/
|
||||
|
||||
# VS Code
|
||||
.vscode/
|
||||
|
||||
# macOS
|
||||
.DS_Store
|
||||
.AppleDouble
|
||||
.LSOverride
|
||||
Icon?
|
||||
._*
|
||||
.Spotlight-V100
|
||||
.Trashes
|
||||
AppleDskTp
|
||||
|
||||
# Windows
|
||||
Thumbs.db
|
||||
ehthumbs.db
|
||||
Desktop.ini
|
||||
$RECYCLE.BIN/
|
||||
Windows/Temp/
|
||||
*.cab
|
||||
*.msi
|
||||
*.msp
|
||||
*.tmp
|
||||
|
||||
# Logs
|
||||
logs/
|
||||
*.log
|
||||
|
||||
# Temp files
|
||||
tmp/
|
||||
temp/
|
||||
|
||||
# Backup files
|
||||
*.bak
|
||||
*.backup
|
||||
*.old
|
||||
*.orig
|
||||
|
||||
# Project specific
|
||||
*.pyc
|
||||
*.pyo
|
||||
*.pyd
|
||||
*.py.class
|
||||
*.pyc.orig
|
||||
*.pyc~*
|
||||
|
||||
# Application data
|
||||
/resources/user_data/
|
||||
/resources/cache/
|
||||
|
||||
# Test reports
|
||||
htmlcov/
|
||||
.coverage
|
||||
.coverage.*
|
||||
nosetests.xml
|
||||
coverage.xml
|
||||
*.cover
|
||||
*.py,cover
|
||||
|
||||
# Virtual environments
|
||||
venv/
|
||||
env/
|
||||
.venv/
|
||||
.env/
|
||||
|
||||
# IDE
|
||||
.idea/
|
||||
|
||||
# Local configuration
|
||||
config/local_settings.json
|
||||
@ -1,8 +0,0 @@
|
||||
# 默认忽略的文件
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
# 基于编辑器的 HTTP 客户端请求
|
||||
/httpRequests/
|
||||
# Datasource local storage ignored files
|
||||
/dataSources/
|
||||
/dataSources.local.xml
|
||||
@ -1 +0,0 @@
|
||||
constants.py
|
||||
@ -1,10 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="PYTHON_MODULE" version="4">
|
||||
<component name="NewModuleRootManager">
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<excludeFolder url="file://$MODULE_DIR$/.venv" />
|
||||
</content>
|
||||
<orderEntry type="jdk" jdkName="Python 3.9" jdkType="Python SDK" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
||||
@ -1,6 +0,0 @@
|
||||
<component name="InspectionProjectProfileManager">
|
||||
<settings>
|
||||
<option name="USE_PROJECT_PROFILE" value="false" />
|
||||
<version value="1.0" />
|
||||
</settings>
|
||||
</component>
|
||||
@ -1,7 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Black">
|
||||
<option name="sdkName" value="Python 3.13 (Curriculum_Design)" />
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.9" project-jdk-type="Python SDK" />
|
||||
</project>
|
||||
@ -1,8 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/Curriculum_Design.iml" filepath="$PROJECT_DIR$/.idea/Curriculum_Design.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
||||
@ -1,7 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="" vcs="Git" />
|
||||
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
||||
@ -1,11 +1,8 @@
|
||||
python-docx>=0.8.11
|
||||
python-docx>=0.8.10
|
||||
PyPDF2>=1.26.0
|
||||
ebooklib>=0.17.1
|
||||
<<<<<<< HEAD
|
||||
PyQt5>=5.15.0
|
||||
=======
|
||||
PyQt5>=5.15
|
||||
>>>>>>> main
|
||||
requests>=2.28.0
|
||||
requests>=2.25.1
|
||||
beautifulsoup4>=4.11.0
|
||||
pillow>=9.0.0
|
||||
pillow>=9.0.0
|
||||
chardet>=4.0.0
|
||||
@ -0,0 +1,42 @@
|
||||
{
|
||||
"application": {
|
||||
"name": "MagicWord",
|
||||
"version": "1.0.0",
|
||||
"author": "MagicWord Team",
|
||||
"description": "隐私学习软件"
|
||||
},
|
||||
"window": {
|
||||
"default_size": {
|
||||
"width": 800,
|
||||
"height": 600
|
||||
},
|
||||
"minimum_size": {
|
||||
"width": 600,
|
||||
"height": 400
|
||||
},
|
||||
"title": "MagicWord - 隐私学习软件"
|
||||
},
|
||||
"typing": {
|
||||
"default_time_limit": 300,
|
||||
"show_progress_bar": true,
|
||||
"highlight_current_line": true,
|
||||
"auto_save_progress": true
|
||||
},
|
||||
"files": {
|
||||
"supported_formats": [".txt", ".docx"],
|
||||
"auto_backup_enabled": true,
|
||||
"backup_interval_minutes": 30
|
||||
},
|
||||
"network": {
|
||||
"weather_api_key": "YOUR_WEATHER_API_KEY",
|
||||
"quote_api_url": "https://api.quotable.io/random",
|
||||
"timeout_seconds": 10
|
||||
},
|
||||
"appearance": {
|
||||
"theme": "light",
|
||||
"font_family": "Arial",
|
||||
"font_size": 12,
|
||||
"text_color": "#000000",
|
||||
"background_color": "#FFFFFF"
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,87 @@
|
||||
# services/network_service.py
|
||||
import requests
|
||||
import json
|
||||
from typing import Optional, Dict, Any
|
||||
|
||||
class NetworkService:
|
||||
def __init__(self):
|
||||
"""
|
||||
初始化网络服务
|
||||
- 设置API密钥
|
||||
- 初始化缓存
|
||||
"""
|
||||
# TODO: 实现构造函数逻辑
|
||||
pass
|
||||
|
||||
def get_weather_info(self) -> Optional[Dict[str, Any]]:
|
||||
"""
|
||||
获取天气信息
|
||||
- 调用天气API
|
||||
- 解析返回数据
|
||||
- 返回格式化的天气信息
|
||||
"""
|
||||
# TODO: 实现天气信息获取逻辑
|
||||
# 1. 获取用户IP地址
|
||||
# 2. 根据IP获取地理位置
|
||||
# 3. 调用天气API获取天气数据
|
||||
# 4. 解析并格式化数据
|
||||
# 5. 返回天气信息字典
|
||||
pass
|
||||
|
||||
def get_daily_quote(self) -> Optional[str]:
|
||||
"""
|
||||
获取每日一句
|
||||
- 调用名言API
|
||||
- 返回格式化的名言
|
||||
"""
|
||||
# TODO: 实现每日一句获取逻辑
|
||||
# 1. 调用名言API
|
||||
# 2. 解析返回的名言数据
|
||||
# 3. 格式化名言文本
|
||||
# 4. 返回名言字符串
|
||||
pass
|
||||
|
||||
def download_image(self, url: str) -> Optional[bytes]:
|
||||
"""
|
||||
下载图片
|
||||
- 从指定URL下载图片
|
||||
- 返回图片二进制数据
|
||||
"""
|
||||
# TODO: 实现图片下载逻辑
|
||||
# 1. 发送HTTP GET请求获取图片
|
||||
# 2. 检查响应状态码
|
||||
# 3. 返回图片二进制数据
|
||||
pass
|
||||
|
||||
class ImageService:
|
||||
def __init__(self):
|
||||
"""
|
||||
初始化图片服务
|
||||
"""
|
||||
# TODO: 实现构造函数逻辑
|
||||
pass
|
||||
|
||||
def extract_images_from_document(self, file_path: str) -> list:
|
||||
"""
|
||||
从文档中提取图片
|
||||
- 解析文档中的图片
|
||||
- 返回图片列表
|
||||
"""
|
||||
# TODO: 实现图片提取逻辑
|
||||
# 1. 根据文件类型选择解析方法
|
||||
# 2. 提取文档中的图片数据
|
||||
# 3. 返回图片信息列表
|
||||
pass
|
||||
|
||||
def display_image_at_position(self, image_data: bytes, position: int) -> bool:
|
||||
"""
|
||||
在指定位置显示图片
|
||||
- 将图片插入到文本中的指定位置
|
||||
- 返回操作结果
|
||||
"""
|
||||
# TODO: 实现图片显示逻辑
|
||||
# 1. 创建图片对象
|
||||
# 2. 在指定位置插入图片
|
||||
# 3. 更新UI显示
|
||||
# 4. 返回操作结果
|
||||
pass
|
||||
@ -0,0 +1,50 @@
|
||||
# settings/settings_manager.py
|
||||
import json
|
||||
import os
|
||||
from typing import Any, Dict
|
||||
|
||||
class SettingsManager:
|
||||
def __init__(self, config_file: str = "config.json"):
|
||||
"""
|
||||
初始化设置管理器
|
||||
- 指定配置文件路径
|
||||
- 加载现有配置或创建默认配置
|
||||
"""
|
||||
# TODO: 实现构造函数逻辑
|
||||
pass
|
||||
|
||||
def load_settings(self) -> Dict[str, Any]:
|
||||
"""
|
||||
加载设置
|
||||
- 从配置文件读取设置
|
||||
- 返回设置字典
|
||||
"""
|
||||
# TODO: 实现设置加载逻辑
|
||||
pass
|
||||
|
||||
def save_settings(self, settings: Dict[str, Any]) -> bool:
|
||||
"""
|
||||
保存设置
|
||||
- 将设置保存到配置文件
|
||||
- 返回保存结果
|
||||
"""
|
||||
# TODO: 实现设置保存逻辑
|
||||
pass
|
||||
|
||||
def get_setting(self, key: str, default: Any = None) -> Any:
|
||||
"""
|
||||
获取特定设置项
|
||||
- 根据键名获取设置值
|
||||
- 如果不存在返回默认值
|
||||
"""
|
||||
# TODO: 实现获取设置项逻辑
|
||||
pass
|
||||
|
||||
def set_setting(self, key: str, value: Any) -> bool:
|
||||
"""
|
||||
设置特定设置项
|
||||
- 设置指定键的值
|
||||
- 保存到配置文件
|
||||
"""
|
||||
# TODO: 实现设置设置项逻辑
|
||||
pass
|
||||
@ -0,0 +1,148 @@
|
||||
# ui/components.py
|
||||
from PyQt5.QtWidgets import QWidget, QLabel, QPushButton, QVBoxLayout, QHBoxLayout
|
||||
from PyQt5.QtCore import Qt
|
||||
|
||||
class CustomTitleBar(QWidget):
|
||||
def __init__(self, parent=None):
|
||||
"""
|
||||
自定义标题栏
|
||||
- 创建标题栏UI元素
|
||||
- 添加窗口控制按钮
|
||||
"""
|
||||
super().__init__(parent)
|
||||
# TODO: 实现标题栏UI
|
||||
# 1. 创建标题标签
|
||||
# 2. 创建最小化、最大化、关闭按钮
|
||||
# 3. 设置布局和样式
|
||||
# 4. 连接按钮事件
|
||||
pass
|
||||
|
||||
def setup_ui(self):
|
||||
"""
|
||||
设置标题栏UI
|
||||
- 初始化所有UI组件
|
||||
- 设置组件属性和样式
|
||||
"""
|
||||
# TODO: 实现UI设置逻辑
|
||||
# 1. 创建水平布局
|
||||
# 2. 添加标题标签和控制按钮
|
||||
# 3. 设置组件样式
|
||||
pass
|
||||
|
||||
def minimize_window(self):
|
||||
"""
|
||||
最小化窗口
|
||||
- 触发窗口最小化事件
|
||||
"""
|
||||
# TODO: 实现窗口最小化逻辑
|
||||
# 1. 获取父窗口
|
||||
# 2. 调用窗口最小化方法
|
||||
pass
|
||||
|
||||
def maximize_window(self):
|
||||
"""
|
||||
最大化窗口
|
||||
- 切换窗口最大化状态
|
||||
"""
|
||||
# TODO: 实现窗口最大化逻辑
|
||||
# 1. 获取父窗口
|
||||
# 2. 检查当前窗口状态
|
||||
# 3. 切换最大化/还原状态
|
||||
pass
|
||||
|
||||
def close_window(self):
|
||||
"""
|
||||
关闭窗口
|
||||
- 触发窗口关闭事件
|
||||
"""
|
||||
# TODO: 实现窗口关闭逻辑
|
||||
# 1. 获取父窗口
|
||||
# 2. 调用窗口关闭方法
|
||||
pass
|
||||
|
||||
class ProgressBarWidget(QWidget):
|
||||
def __init__(self, parent=None):
|
||||
"""
|
||||
进度条组件
|
||||
- 显示打字练习进度
|
||||
- 显示统计信息
|
||||
"""
|
||||
super().__init__(parent)
|
||||
# TODO: 实现进度条组件初始化
|
||||
# 1. 创建进度条UI元素
|
||||
# 2. 创建统计信息标签
|
||||
# 3. 设置布局
|
||||
pass
|
||||
|
||||
def update_progress(self, progress: float):
|
||||
"""
|
||||
更新进度条
|
||||
- 设置进度值
|
||||
- 更新显示
|
||||
"""
|
||||
# TODO: 实现进度更新逻辑
|
||||
# 1. 更新进度条数值
|
||||
# 2. 刷新UI显示
|
||||
pass
|
||||
|
||||
def update_stats(self, wpm: int, accuracy: float, time_elapsed: int):
|
||||
"""
|
||||
更新统计信息
|
||||
- 显示WPM、准确率、用时等信息
|
||||
"""
|
||||
# TODO: 实现统计信息更新逻辑
|
||||
# 1. 更新WPM标签
|
||||
# 2. 更新准确率标签
|
||||
# 3. 更新用时标签
|
||||
pass
|
||||
|
||||
class TextDisplayWidget(QWidget):
|
||||
def __init__(self, parent=None):
|
||||
"""
|
||||
文本显示组件
|
||||
- 显示待练习文本
|
||||
- 高亮当前字符
|
||||
- 显示用户输入
|
||||
"""
|
||||
super().__init__(parent)
|
||||
# TODO: 实现文本显示组件初始化
|
||||
# 1. 创建文本显示区域
|
||||
# 2. 设置文本样式
|
||||
# 3. 初始化高亮相关属性
|
||||
pass
|
||||
|
||||
def set_text(self, text: str):
|
||||
"""
|
||||
设置显示文本
|
||||
- 更新显示内容
|
||||
- 重置高亮状态
|
||||
"""
|
||||
# TODO: 实现文本设置逻辑
|
||||
# 1. 更新内部文本内容
|
||||
# 2. 重置高亮位置
|
||||
# 3. 刷新UI显示
|
||||
pass
|
||||
|
||||
def highlight_character(self, position: int):
|
||||
"""
|
||||
高亮指定位置字符
|
||||
- 更新高亮位置
|
||||
- 刷新显示
|
||||
"""
|
||||
# TODO: 实现字符高亮逻辑
|
||||
# 1. 计算高亮范围
|
||||
# 2. 应用高亮样式
|
||||
# 3. 滚动到高亮位置
|
||||
pass
|
||||
|
||||
def show_user_input(self, input_text: str):
|
||||
"""
|
||||
显示用户输入
|
||||
- 在文本下方显示用户输入
|
||||
- 高亮正确/错误字符
|
||||
"""
|
||||
# TODO: 实现用户输入显示逻辑
|
||||
# 1. 对比用户输入与原文
|
||||
# 2. 分别高亮正确和错误字符
|
||||
# 3. 更新输入显示区域
|
||||
pass
|
||||
@ -0,0 +1,35 @@
|
||||
# utils/helper_functions.py
|
||||
import os
|
||||
import hashlib
|
||||
from typing import Optional
|
||||
|
||||
class Utils:
|
||||
@staticmethod
|
||||
def detect_encoding(file_path: str) -> str:
|
||||
"""
|
||||
检测文件编码
|
||||
- 尝试多种编码格式
|
||||
- 返回最可能的编码
|
||||
"""
|
||||
# TODO: 实现编码检测逻辑
|
||||
pass
|
||||
|
||||
@staticmethod
|
||||
def format_file_size(size_bytes: int) -> str:
|
||||
"""
|
||||
格式化文件大小
|
||||
- 将字节数转换为可读格式
|
||||
- 返回格式化字符串
|
||||
"""
|
||||
# TODO: 实现文件大小格式化逻辑
|
||||
pass
|
||||
|
||||
@staticmethod
|
||||
def calculate_file_hash(file_path: str) -> str:
|
||||
"""
|
||||
计算文件哈希值
|
||||
- 使用SHA256算法
|
||||
- 返回哈希字符串
|
||||
"""
|
||||
# TODO: 实现文件哈希计算逻辑
|
||||
pass
|
||||
@ -0,0 +1,88 @@
|
||||
# tests/test_file_operations.py
|
||||
import sys
|
||||
import os
|
||||
import unittest
|
||||
import tempfile
|
||||
import shutil
|
||||
from pathlib import Path
|
||||
|
||||
# 添加src目录到Python路径
|
||||
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..', 'src'))
|
||||
|
||||
class TestFileManager(unittest.TestCase):
|
||||
def setUp(self):
|
||||
"""
|
||||
测试前准备
|
||||
- 创建临时目录和测试文件
|
||||
"""
|
||||
# TODO: 实现测试环境初始化逻辑
|
||||
# 1. 创建临时测试目录
|
||||
# 2. 创建测试文件
|
||||
# 3. 导入文件管理模块
|
||||
# 4. 创建文件管理器实例
|
||||
pass
|
||||
|
||||
def tearDown(self):
|
||||
"""
|
||||
测试后清理
|
||||
- 删除临时目录和文件
|
||||
"""
|
||||
# TODO: 实现测试环境清理逻辑
|
||||
# 1. 删除临时测试目录
|
||||
# 2. 清理文件管理器状态
|
||||
pass
|
||||
|
||||
def test_list_files(self):
|
||||
"""
|
||||
测试文件列表功能
|
||||
- 验证文件列表准确性
|
||||
- 检查扩展名过滤功能
|
||||
"""
|
||||
# TODO: 实现文件列表测试逻辑
|
||||
# 1. 在临时目录中创建不同类型文件
|
||||
# 2. 调用list_files方法
|
||||
# 3. 验证返回文件列表
|
||||
# 4. 测试扩展名过滤功能
|
||||
pass
|
||||
|
||||
def test_copy_file(self):
|
||||
"""
|
||||
测试文件复制功能
|
||||
- 验证文件复制正确性
|
||||
- 检查异常处理
|
||||
"""
|
||||
# TODO: 实现文件复制测试逻辑
|
||||
# 1. 准备源文件
|
||||
# 2. 调用copy_file方法
|
||||
# 3. 验证目标文件是否存在且内容正确
|
||||
# 4. 测试异常情况(源文件不存在等)
|
||||
pass
|
||||
|
||||
def test_move_file(self):
|
||||
"""
|
||||
测试文件移动功能
|
||||
- 验证文件移动正确性
|
||||
- 检查源文件是否被删除
|
||||
"""
|
||||
# TODO: 实现文件移动测试逻辑
|
||||
# 1. 准备源文件
|
||||
# 2. 调用move_file方法
|
||||
# 3. 验证目标文件是否存在且内容正确
|
||||
# 4. 验证源文件是否已被删除
|
||||
pass
|
||||
|
||||
def test_delete_file(self):
|
||||
"""
|
||||
测试文件删除功能
|
||||
- 验证文件删除成功性
|
||||
- 检查异常处理
|
||||
"""
|
||||
# TODO: 实现文件删除测试逻辑
|
||||
# 1. 准备测试文件
|
||||
# 2. 调用delete_file方法
|
||||
# 3. 验证文件是否已被删除
|
||||
# 4. 测试异常情况(文件不存在等)
|
||||
pass
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
@ -0,0 +1,71 @@
|
||||
# tests/test_input_processor.py
|
||||
import sys
|
||||
import os
|
||||
import unittest
|
||||
from PyQt5.QtCore import QEvent, Qt
|
||||
from PyQt5.QtGui import QKeyEvent
|
||||
|
||||
# 添加src目录到Python路径
|
||||
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..', 'src'))
|
||||
|
||||
class TestInputProcessor(unittest.TestCase):
|
||||
def setUp(self):
|
||||
"""
|
||||
测试前准备
|
||||
"""
|
||||
# TODO: 实现测试环境初始化逻辑
|
||||
# 1. 导入输入处理模块
|
||||
# 2. 创建输入处理器实例
|
||||
# 3. 初始化测试变量
|
||||
pass
|
||||
|
||||
def tearDown(self):
|
||||
"""
|
||||
测试后清理
|
||||
"""
|
||||
# TODO: 实现测试环境清理逻辑
|
||||
# 1. 重置输入处理器状态
|
||||
# 2. 清理测试数据
|
||||
pass
|
||||
|
||||
def test_process_key_event(self):
|
||||
"""
|
||||
测试按键事件处理
|
||||
- 验证不同按键的处理结果
|
||||
- 检查信号发送
|
||||
"""
|
||||
# TODO: 实现按键事件处理测试逻辑
|
||||
# 1. 创建不同类型的按键事件
|
||||
# 2. 调用process_key_event方法
|
||||
# 3. 验证返回结果
|
||||
# 4. 检查信号是否正确发送
|
||||
pass
|
||||
|
||||
def test_input_validation(self):
|
||||
"""
|
||||
测试输入验证功能
|
||||
- 验证字符验证准确性
|
||||
- 检查单词验证结果
|
||||
"""
|
||||
# TODO: 实现输入验证测试逻辑
|
||||
# 1. 准备测试输入和期望文本
|
||||
# 2. 调用验证方法
|
||||
# 3. 验证验证结果
|
||||
# 4. 检查边界情况处理
|
||||
pass
|
||||
|
||||
def test_accuracy_calculation(self):
|
||||
"""
|
||||
测试准确率计算
|
||||
- 验证准确率计算正确性
|
||||
- 检查特殊输入情况
|
||||
"""
|
||||
# TODO: 实现准确率计算测试逻辑
|
||||
# 1. 准备测试输入和期望文本
|
||||
# 2. 调用准确率计算方法
|
||||
# 3. 验证计算结果
|
||||
# 4. 检查边界情况(空输入、完全错误等)
|
||||
pass
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
@ -0,0 +1,60 @@
|
||||
# tests/test_main.py
|
||||
import sys
|
||||
import os
|
||||
import unittest
|
||||
|
||||
# 添加src目录到Python路径
|
||||
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..', 'src'))
|
||||
|
||||
class TestMagicWordApplication(unittest.TestCase):
|
||||
def setUp(self):
|
||||
"""
|
||||
测试前准备
|
||||
- 初始化测试环境
|
||||
- 创建测试数据
|
||||
"""
|
||||
# TODO: 实现测试环境初始化逻辑
|
||||
# 1. 创建临时测试目录
|
||||
# 2. 准备测试文件
|
||||
# 3. 初始化被测试对象
|
||||
pass
|
||||
|
||||
def tearDown(self):
|
||||
"""
|
||||
测试后清理
|
||||
- 清理测试数据
|
||||
- 恢复环境状态
|
||||
"""
|
||||
# TODO: 实现测试环境清理逻辑
|
||||
# 1. 删除临时测试文件
|
||||
# 2. 清理测试目录
|
||||
# 3. 重置全局状态
|
||||
pass
|
||||
|
||||
def test_application_startup(self):
|
||||
"""
|
||||
测试应用启动
|
||||
- 验证应用能够正常启动
|
||||
- 检查初始状态
|
||||
"""
|
||||
# TODO: 实现应用启动测试逻辑
|
||||
# 1. 导入主应用模块
|
||||
# 2. 创建应用实例
|
||||
# 3. 验证应用初始化状态
|
||||
# 4. 检查必要组件是否加载
|
||||
pass
|
||||
|
||||
def test_file_operations(self):
|
||||
"""
|
||||
测试文件操作
|
||||
- 验证文件打开、保存等功能
|
||||
"""
|
||||
# TODO: 实现文件操作测试逻辑
|
||||
# 1. 准备测试文件
|
||||
# 2. 测试文件打开功能
|
||||
# 3. 测试文件保存功能
|
||||
# 4. 验证文件内容正确性
|
||||
pass
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
@ -0,0 +1,73 @@
|
||||
# tests/test_network_service.py
|
||||
import sys
|
||||
import os
|
||||
import unittest
|
||||
from unittest.mock import patch, Mock
|
||||
|
||||
# 添加src目录到Python路径
|
||||
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..', 'src'))
|
||||
|
||||
class TestNetworkService(unittest.TestCase):
|
||||
def setUp(self):
|
||||
"""
|
||||
测试前准备
|
||||
"""
|
||||
# TODO: 实现测试环境初始化逻辑
|
||||
# 1. 导入网络服务模块
|
||||
# 2. 创建网络服务实例
|
||||
# 3. 准备测试数据
|
||||
pass
|
||||
|
||||
def tearDown(self):
|
||||
"""
|
||||
测试后清理
|
||||
"""
|
||||
# TODO: 实现测试环境清理逻辑
|
||||
# 1. 重置网络服务状态
|
||||
# 2. 清理模拟对象
|
||||
pass
|
||||
|
||||
@patch('requests.get')
|
||||
def test_get_weather_info(self, mock_get):
|
||||
"""
|
||||
测试获取天气信息功能
|
||||
- 模拟网络请求
|
||||
- 验证返回数据格式
|
||||
"""
|
||||
# TODO: 实现天气信息获取测试逻辑
|
||||
# 1. 准备模拟响应数据
|
||||
# 2. 设置mock对象返回值
|
||||
# 3. 调用被测试方法
|
||||
# 4. 验证返回数据格式和内容
|
||||
pass
|
||||
|
||||
@patch('requests.get')
|
||||
def test_get_daily_quote(self, mock_get):
|
||||
"""
|
||||
测试获取每日一句功能
|
||||
- 模拟网络请求
|
||||
- 验证返回数据
|
||||
"""
|
||||
# TODO: 实现每日一句获取测试逻辑
|
||||
# 1. 准备模拟响应数据
|
||||
# 2. 设置mock对象返回值
|
||||
# 3. 调用被测试方法
|
||||
# 4. 验证返回数据
|
||||
pass
|
||||
|
||||
@patch('requests.get')
|
||||
def test_download_image(self, mock_get):
|
||||
"""
|
||||
测试图片下载功能
|
||||
- 模拟网络请求
|
||||
- 验证返回的图片数据
|
||||
"""
|
||||
# TODO: 实现图片下载测试逻辑
|
||||
# 1. 准备模拟响应数据(图片二进制数据)
|
||||
# 2. 设置mock对象返回值
|
||||
# 3. 调用被测试方法
|
||||
# 4. 验证返回的图片数据
|
||||
pass
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
Loading…
Reference in new issue