fix: the download bar fits the terminal

A 2 GB part drew a 98-column line, and on an 80-column console every redraw wrapped and left a copy behind. The bar now shrinks to the width and goes below ten columns of room.
This commit is contained in:
Abdessamad Derraz committed 2026-10-20 04:43:12 +02:00
1 parent d087caec40
commit 2bb4dc9187
2 files changed
+31 -6

No files matched your search

+15
View File
@@ -252,6 +252,21 @@ class TestJoinVolumes(unittest.TestCase):
self.assertEqual(zf.testzip(), None)
class TestProgressLineWidth(unittest.TestCase):
"""The bar was 98 columns for a 2 GB part: on an 80-column console each
redraw wrapped and left a line behind."""
def test_the_line_fits_every_width(self):
from download import _progress_line
for columns in (20, 40, 80, 120, 200):
for done in (0, 1_000_000_000, 2_000_000_000):
with self.subTest(columns=columns, done=done):
line = _progress_line("part 1/2 ", done, 2_000_000_000, columns)
self.assertLess(len(line), columns)
self.assertIn("%", line)
class TestStagingIsolation(unittest.TestCase):
"""Two downloads into one BIOS folder must not share a staging directory."""