aboutsummaryrefslogtreecommitdiff
path: root/app/tests/test_backends_common.py
diff options
context:
space:
mode:
authorhistoria <historiavg@proton.me>2026-09-01 14:32:05 -0400
committerhistoria <historiavg@proton.me>2026-09-01 14:32:05 -0400
commit6cfcd564c0684c52618235e6366f4a81c02b9a5b (patch)
tree55321760a8103bc6b5d79489fac4135a60e6e3ba /app/tests/test_backends_common.py
parentdc6e7cd43029da62dabe2513fb5aa8a34df1bd6d (diff)
downloadtts-audiobook-generator-6cfcd564c0684c52618235e6366f4a81c02b9a5b.tar.gz
slop refactor/dedup
Diffstat (limited to 'app/tests/test_backends_common.py')
-rw-r--r--app/tests/test_backends_common.py28
1 files changed, 28 insertions, 0 deletions
diff --git a/app/tests/test_backends_common.py b/app/tests/test_backends_common.py
index 08ffc2c..68a5543 100644
--- a/app/tests/test_backends_common.py
+++ b/app/tests/test_backends_common.py
@@ -51,6 +51,34 @@ class RunConsoleSubprocessStreamingTests(unittest.TestCase):
on_cancel=lambda: touched.append(True))
self.assertEqual(touched, [True])
+ def test_carriage_return_progress_streams_incrementally(self):
+ # tqdm/HuggingFace-style \r-only progress: a readline-based reader
+ # blocked until the next \n, so the updates arrived in one burst
+ # (or the stall watchdog fired first). Each \r segment must be
+ # emitted as its own line.
+ lines = []
+ rc = common.run_console_subprocess(
+ [sys.executable, "-c",
+ "import sys, time\n"
+ "for i in range(4):\n"
+ " sys.stdout.write(f'pct {i}\\r'); sys.stdout.flush()\n"
+ " time.sleep(0.2)\n"
+ "sys.stdout.write('done\\n'); sys.stdout.flush()\n"],
+ emit=lines.append, stall_timeout=1.0)
+ self.assertEqual(rc, 0)
+ self.assertEqual(lines, [f"pct {i}" for i in range(4)] + ["done"])
+
+ def test_url_with_port_preserves_userinfo_and_ipv6(self):
+ self.assertEqual(
+ common.url_with_port("http://user:pass@host:8000", 8080),
+ "http://user:pass@host:8080")
+ self.assertEqual(
+ common.url_with_port("http://[::1]:8000", 8080),
+ "http://[::1]:8080")
+ self.assertEqual(
+ common.url_with_port("http://host:8000/path", 8080),
+ "http://host:8080/path")
+
class RunConsoleSubprocessStallTests(unittest.TestCase):
"""The no-output watchdog: a silent child is killed and reported 124."""