Skip to content

Commit

Permalink
Show 3 digits instead of 1 in file size strings. (#296)
Browse files Browse the repository at this point in the history
Co-authored-by: James Lamb <[email protected]>
  • Loading branch information
bdice and jameslamb authored Jan 28, 2025
1 parent 19bc69c commit c10e3da
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/pydistcheck/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,4 @@ def __ne__(self, other: object) -> bool:

def __str__(self) -> str:
num_bytes, unit_str = _recommend_size_str(self.total_size_bytes)
return f"{round(num_bytes, 1)}{unit_str}"
return f"{round(num_bytes, 3)}{unit_str}"
2 changes: 1 addition & 1 deletion tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,7 @@ def test_check_prefers_keyword_args_to_pyproject_toml_and_defaults(
result,
(
r"^1\. \[distro\-too\-large\-uncompressed\] Uncompressed size [0-9]+\.[0-9]+K is "
r"larger than the allowed size \(0\.1K\)\.$"
r"larger than the allowed size \(0\.12K\)\.$"
),
)
_assert_log_matches_pattern(result, "errors found while checking\\: 1")
Expand Down
10 changes: 5 additions & 5 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,14 @@ def test_file_size_from_number_switches_unit_str_based_on_size():
@pytest.mark.parametrize(
("file_size", "expected_str"),
[
(_FileSize.from_number(110), "0.1K"),
(_FileSize.from_number(150), "0.1K"),
(_FileSize.from_number(110), "0.107K"),
(_FileSize.from_number(150), "0.146K"),
(_FileSize.from_number(1024), "1.0K"),
(_FileSize.from_number(100 * 1024), "100.0K"),
(_FileSize.from_number(200 * 1024), "0.2M"),
(_FileSize.from_number(200 * 1024), "0.195M"),
(_FileSize.from_number(1024**2), "1.0M"),
(_FileSize.from_number(400 * 1024**2), "0.4G"),
(_FileSize.from_number(405 * 1024**2), "0.4G"),
(_FileSize.from_number(400 * 1024**2), "0.391G"),
(_FileSize.from_number(405 * 1024**2), "0.396G"),
(_FileSize.from_number(1024**3), "1.0G"),
(_FileSize.from_number(int(7.5 * 1024**3)), "7.5G"),
],
Expand Down

0 comments on commit c10e3da

Please sign in to comment.