diff options
Diffstat (limited to 'app/tests/test_backends_common.py')
| -rw-r--r-- | app/tests/test_backends_common.py | 28 |
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.""" |
