单元测试和改进
This commit is contained in:
63
tests/conftest.py
Normal file
63
tests/conftest.py
Normal file
@@ -0,0 +1,63 @@
|
||||
"""
|
||||
Test configuration and fixtures for HeurAMS tests.
|
||||
"""
|
||||
import pytest
|
||||
import tempfile
|
||||
import os
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def temp_config_file():
|
||||
"""Create a temporary config file for testing."""
|
||||
with tempfile.NamedTemporaryFile(mode='w', suffix='.json', delete=False) as f:
|
||||
f.write('''{
|
||||
"algorithm": "sm2",
|
||||
"default_ease": 2.5,
|
||||
"learning_steps": [1, 10],
|
||||
"graduating_interval": 1,
|
||||
"easy_interval": 4
|
||||
}''')
|
||||
temp_path = f.name
|
||||
|
||||
yield temp_path
|
||||
|
||||
# Cleanup
|
||||
if os.path.exists(temp_path):
|
||||
os.unlink(temp_path)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def sample_atom_data():
|
||||
"""Sample atom data for testing."""
|
||||
return {
|
||||
"nucleon": {
|
||||
"content": "What is the capital of France?",
|
||||
"answer": "Paris"
|
||||
},
|
||||
"electron": {
|
||||
"ease": 2.5,
|
||||
"interval": 1,
|
||||
"repetitions": 0,
|
||||
"last_review": None
|
||||
},
|
||||
"orbital": {
|
||||
"learning_steps": [1, 10],
|
||||
"graduating_interval": 1,
|
||||
"easy_interval": 4
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def sample_markdown_content():
|
||||
"""Sample markdown content for testing."""
|
||||
return """
|
||||
# Test Document
|
||||
|
||||
This is a test document with some {{c1::cloze}} deletions.
|
||||
|
||||
Here's another {{c2::cloze deletion}} for testing.
|
||||
|
||||
What is the capital of {{c3::France}}?
|
||||
"""
|
||||
Reference in New Issue
Block a user