From b2ede1c4814a9895d7cedda09299fb370caf8186 Mon Sep 17 00:00:00 2001 From: Duncan Tourolle Date: Sun, 9 Nov 2025 15:30:10 +0100 Subject: [PATCH] more debug info --- tests/test_settings_overlay.py | 55 +++++++++++++++++++++++++++------- 1 file changed, 44 insertions(+), 11 deletions(-) diff --git a/tests/test_settings_overlay.py b/tests/test_settings_overlay.py index 1036738..d5e8023 100644 --- a/tests/test_settings_overlay.py +++ b/tests/test_settings_overlay.py @@ -24,21 +24,54 @@ class TestSettingsOverlay(unittest.TestCase): def setUp(self): """Set up test reader with a book""" + import os + import zipfile + self.reader = EbookReader(page_size=(800, 1200)) - # Load a test EPUB - test_epub = Path(__file__).parent / 'data' / 'library-epub' / 'alice.epub' - if not test_epub.exists(): - # Try to find any EPUB in test data - epub_dir = Path(__file__).parent / 'data' / 'library-epub' - epubs = list(epub_dir.glob('*.epub')) - if epubs: - test_epub = epubs[0] - else: - self.skipTest("No test EPUB files available") + # Load a test EPUB - use any available EPUB in test data + epub_dir = Path(__file__).parent / 'data' / 'library-epub' + epubs = list(epub_dir.glob('*.epub')) + if not epubs: + self.skipTest("No test EPUB files available") + test_epub = epubs[0] + + # Debug logging + print(f"\n=== EPUB Loading Debug Info ===") + print(f"Test EPUB path: {test_epub}") + print(f"Absolute path: {test_epub.absolute()}") + print(f"File exists: {test_epub.exists()}") + print(f"File size: {test_epub.stat().st_size if test_epub.exists() else 'N/A'}") + print(f"Is file: {test_epub.is_file() if test_epub.exists() else 'N/A'}") + print(f"Readable: {os.access(test_epub, os.R_OK) if test_epub.exists() else 'N/A'}") + + # Test if it's a valid ZIP + if test_epub.exists(): + try: + with zipfile.ZipFile(test_epub, 'r') as zf: + print(f"Valid ZIP: True") + print(f"Files in ZIP: {len(zf.namelist())}") + print(f"First 3 files: {zf.namelist()[:3]}") + except Exception as e: + print(f"ZIP validation error: {e}") + + # Try to load success = self.reader.load_epub(str(test_epub)) - self.assertTrue(success, "Failed to load test EPUB") + + if not success: + print(f"=== Load failed ===") + # Try loading with pyWebLayout directly for more detailed error + try: + from pyWebLayout.io.readers.epub_reader import read_epub + book = read_epub(str(test_epub)) + print(f"Direct pyWebLayout load: SUCCESS (unexpected!)") + except Exception as e: + print(f"Direct pyWebLayout load error: {e}") + import traceback + traceback.print_exc() + + self.assertTrue(success, f"Failed to load test EPUB: {test_epub}") def tearDown(self): """Clean up"""