mirror of
https://github.com/denizsafak/abogen.git
synced 2026-07-18 13:40:27 +02:00
Reformat using black
This commit is contained in:
@@ -6,7 +6,7 @@ import time
|
||||
from PyQt6.QtWidgets import QApplication
|
||||
|
||||
# Ensure we can import the module
|
||||
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
|
||||
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), "..")))
|
||||
|
||||
from abogen.book_handler import HandlerDialog
|
||||
from ebooklib import epub
|
||||
@@ -14,6 +14,7 @@ from ebooklib import epub
|
||||
# We need a QApplication instance for QWriter/QDialog
|
||||
app = QApplication(sys.argv)
|
||||
|
||||
|
||||
class TestBookHandlerRegression(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
@@ -48,26 +49,29 @@ class TestBookHandlerRegression(unittest.TestCase):
|
||||
# HandlerDialog starts processing in a background thread in __init__
|
||||
# We assume headless environment, so we won't show it.
|
||||
# But we need to wait for the thread to finish.
|
||||
|
||||
|
||||
dialog = HandlerDialog(self.sample_epub_path)
|
||||
|
||||
|
||||
# Wait for thread to finish
|
||||
# The dialog emits no signal publicly, but we can check internal state or thread
|
||||
|
||||
|
||||
start_time = time.time()
|
||||
while time.time() - start_time < 5:
|
||||
# HandlerDialog logic:
|
||||
# _loader_thread.finished connect to _on_load_finished
|
||||
# _on_load_finished populates content_texts and content_lengths
|
||||
|
||||
|
||||
# We can check if content_texts is populated
|
||||
if dialog.content_texts:
|
||||
break
|
||||
app.processEvents() # Process Qt events to let thread signals propagate
|
||||
app.processEvents() # Process Qt events to let thread signals propagate
|
||||
time.sleep(0.1)
|
||||
|
||||
self.assertTrue(len(dialog.content_texts) > 0, "HandlerDialog failed to process content in time")
|
||||
|
||||
|
||||
self.assertTrue(
|
||||
len(dialog.content_texts) > 0,
|
||||
"HandlerDialog failed to process content in time",
|
||||
)
|
||||
|
||||
# Validate content similar to what we expect
|
||||
# intro.xhtml should be there
|
||||
found_intro = False
|
||||
@@ -80,5 +84,6 @@ class TestBookHandlerRegression(unittest.TestCase):
|
||||
# Cleanup
|
||||
dialog.close()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
Reference in New Issue
Block a user