mirror of https://github.com/Textualize/rich.git
Change download column test to not use progress and console
Add new version in CHANGELOG.md
This commit is contained in:
parent
1778cdf71f
commit
82c2f44cd2
|
@ -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/),
|
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).
|
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
|
## [8.0.0] - 2020-10-03
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
@ -19,7 +25,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
- Changed Style.empty to Style.null to better reflect what it does
|
- Changed Style.empty to Style.null to better reflect what it does
|
||||||
- Optimized combining styles involving a null style
|
- Optimized combining styles involving a null style
|
||||||
- Change error messages in Style.parse to read better
|
- Change error messages in Style.parse to read better
|
||||||
- Change the render prefix to correspond to the decimal units in progress
|
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
|
|
|
@ -79,6 +79,28 @@ def test_time_remaining_column():
|
||||||
assert str(text) == "0:01:00"
|
assert str(text) == "0:01:00"
|
||||||
|
|
||||||
|
|
||||||
|
def test_download_progress_uses_decimal_units() -> None:
|
||||||
|
|
||||||
|
column = DownloadColumn()
|
||||||
|
|
||||||
|
size_params = [pow(10, ex) for ex in range(3, 25, 3)]
|
||||||
|
units = ["KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"]
|
||||||
|
|
||||||
|
# Check rendering params for all sizes
|
||||||
|
for i in range(len(size_params)):
|
||||||
|
test_task = Task(
|
||||||
|
i, f"test_{units[i]}", size_params[i], 0, _get_time=lambda: 1.0
|
||||||
|
)
|
||||||
|
list_rendered = []
|
||||||
|
for n in range(10):
|
||||||
|
test_task.completed = size_params[i] / 10 * (n + 1)
|
||||||
|
list_rendered.append(str(column.render(test_task)))
|
||||||
|
expected = [f"0.{completed}/1.0 {units[i]}" for completed in range(1, 10)] + [
|
||||||
|
f"1.0/1.0 {units[i]}"
|
||||||
|
]
|
||||||
|
assert list_rendered == expected
|
||||||
|
|
||||||
|
|
||||||
def test_task_ids():
|
def test_task_ids():
|
||||||
progress = make_progress()
|
progress = make_progress()
|
||||||
assert progress.task_ids == [0, 1, 2, 4]
|
assert progress.task_ids == [0, 1, 2, 4]
|
||||||
|
@ -254,40 +276,6 @@ def test_columns() -> None:
|
||||||
assert result == expected
|
assert result == expected
|
||||||
|
|
||||||
|
|
||||||
def test_download_progress_uses_decimal_units() -> None:
|
|
||||||
console = Console(
|
|
||||||
file=io.StringIO(),
|
|
||||||
force_terminal=True,
|
|
||||||
width=80,
|
|
||||||
log_time_format="[TIME]",
|
|
||||||
color_system="truecolor",
|
|
||||||
legacy_windows=False,
|
|
||||||
log_path=False,
|
|
||||||
)
|
|
||||||
progress = Progress(
|
|
||||||
"test",
|
|
||||||
DownloadColumn(),
|
|
||||||
transient=True,
|
|
||||||
console=console,
|
|
||||||
auto_refresh=False,
|
|
||||||
get_time=MockClock(),
|
|
||||||
)
|
|
||||||
size_params = [pow(10, ex) for ex in range(3, 25, 3)]
|
|
||||||
units = ["KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"]
|
|
||||||
|
|
||||||
# Check rendering params for all sizes
|
|
||||||
for i in range(len(size_params)):
|
|
||||||
test_task = progress.add_task(f"test_{units[i]}", total=size_params[i])
|
|
||||||
list_rendered = []
|
|
||||||
for n in range(10):
|
|
||||||
progress.advance(test_task, size_params[i] / 10)
|
|
||||||
list_rendered.append(str(progress.columns[1].render(progress.tasks[i])))
|
|
||||||
expected = [f"0.{completed}/1.0 {units[i]}" for completed in range(1, 10)] + [
|
|
||||||
f"1.0/1.0 {units[i]}"
|
|
||||||
]
|
|
||||||
assert list_rendered == expected
|
|
||||||
|
|
||||||
|
|
||||||
def test_task_create() -> None:
|
def test_task_create() -> None:
|
||||||
task = Task(TaskID(1), "foo", 100, 0, _get_time=lambda: 1)
|
task = Task(TaskID(1), "foo", 100, 0, _get_time=lambda: 1)
|
||||||
assert task.elapsed is None
|
assert task.elapsed is None
|
||||||
|
|
Loading…
Reference in New Issue