Files
wehub-resource-sync e940d071f0
Automated Testing / Code Quality (Lint & Format) (push) Has been cancelled
Automated Testing / Security Scan (push) Has been cancelled
Automated Testing / Type Checking (push) Has been cancelled
Automated Testing / Build EPUB Artifact (push) Has been cancelled
Automated Testing / Test Summary (push) Has been cancelled
Automated Testing / Unit Tests (Python 3.11) (push) Has been cancelled
Automated Testing / Unit Tests (Python 3.10) (push) Has been cancelled
Automated Testing / Unit Tests (Python 3.12) (push) Has been cancelled
Documentation Checks / Summary (push) Has been cancelled
Documentation Checks / Cross-reference Check (push) Has been cancelled
Documentation Checks / Check Links (push) Successful in 8m28s
Documentation Checks / Mermaid Syntax (push) Failing after 5m21s
Deploy Website to GitHub Pages / Deploy to GitHub Pages (push) Has been cancelled
Deploy Website to GitHub Pages / Build static site (push) Has been cancelled
Documentation Checks / Markdown Linting (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 12:35:36 +08:00

59 lines
1.5 KiB
Python

"""Pytest configuration and shared fixtures for EPUB builder tests."""
from __future__ import annotations
import logging
import sys
from pathlib import Path
import pytest
# Add parent directory to path for imports
sys.path.insert(0, str(Path(__file__).parent.parent))
from build_epub import BuildState, EPUBConfig, setup_logging
@pytest.fixture
def tmp_project(tmp_path: Path) -> Path:
"""Create a minimal project structure for testing."""
# Create root markdown file
readme = tmp_path / "README.md"
readme.write_text("# Test Project\n\nThis is a test.")
# Create a chapter directory
chapter_dir = tmp_path / "01-test-chapter"
chapter_dir.mkdir()
(chapter_dir / "README.md").write_text("# Chapter Overview\n\nOverview content.")
(chapter_dir / "section.md").write_text("# Section\n\nSection content.")
# Create a proper PNG logo using PIL
from PIL import Image as PILImage
logo_path = tmp_path / "claude-howto-logo.png"
img = PILImage.new("RGB", (100, 100), color=(26, 26, 46))
img.save(logo_path, "PNG")
return tmp_path
@pytest.fixture
def config(tmp_project: Path) -> EPUBConfig:
"""Create a test configuration."""
return EPUBConfig(
root_path=tmp_project,
output_path=tmp_project / "test.epub",
)
@pytest.fixture
def state() -> BuildState:
"""Create a fresh build state."""
return BuildState()
@pytest.fixture
def logger() -> logging.Logger:
"""Create a test logger."""
return setup_logging(verbose=False)