mirror of https://github.com/Textualize/rich.git
Merge pull request #326 from amartya-dev/master
Change to binary prefixes in progress.py
This commit is contained in:
commit
054b8e1973
|
@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
|
|||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## [8.0.1] - unreleased
|
||||
|
||||
### Changed
|
||||
|
||||
- Change the render prefix to correspond to the decimal units in progress
|
||||
|
||||
## [8.0.0] - 2020-10-03
|
||||
|
||||
### Added
|
||||
|
|
|
@ -299,7 +299,9 @@ class DownloadColumn(ProgressColumn):
|
|||
completed = int(task.completed)
|
||||
total = int(task.total)
|
||||
unit, suffix = filesize.pick_unit_and_suffix(
|
||||
total, ["bytes", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"], 1024
|
||||
total,
|
||||
["bytes", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"],
|
||||
1000,
|
||||
)
|
||||
completed_ratio = completed / unit
|
||||
total_ratio = total / unit
|
||||
|
|
|
@ -79,6 +79,15 @@ def test_time_remaining_column():
|
|||
assert str(text) == "0:01:00"
|
||||
|
||||
|
||||
def test_download_progress_uses_decimal_units() -> None:
|
||||
|
||||
column = DownloadColumn()
|
||||
test_task = Task(1, "test", 1000, 500, _get_time=lambda: 1.0)
|
||||
rendered_progress = str(column.render(test_task))
|
||||
expected = "0.5/1.0 KB"
|
||||
assert rendered_progress == expected
|
||||
|
||||
|
||||
def test_task_ids():
|
||||
progress = make_progress()
|
||||
assert progress.task_ids == [0, 1, 2, 4]
|
||||
|
|
Loading…
Reference in New Issue