-
Notifications
You must be signed in to change notification settings - Fork 337
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix formatting sonarcloud compliance issue (#1697)
Signed-off-by: Bryce Gattis <brycegattis@yahoo.com>
- Loading branch information
1 parent
71d990b
commit d46901c
Showing
2 changed files
with
49 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# Copyright Contributors to the Rez Project | ||
|
||
|
||
""" | ||
unit tests for 'utils.formatting' module | ||
""" | ||
from rez.tests.util import TestBase | ||
from rez.utils import formatting | ||
|
||
|
||
class TestFormatting(TestBase): | ||
def test_readable_units(self): | ||
readable_units = formatting._readable_units( | ||
0, | ||
formatting.memory_divs | ||
) | ||
self.assertEqual(readable_units, "0 bytes") | ||
|
||
readable_units = formatting._readable_units( | ||
1024, | ||
formatting.memory_divs | ||
) | ||
self.assertEqual(readable_units, "1 Kb") | ||
|
||
readable_units = formatting._readable_units( | ||
1200, | ||
formatting.memory_divs | ||
) | ||
self.assertEqual(readable_units, "1.2 Kb") | ||
|
||
readable_units = formatting._readable_units( | ||
-30000, | ||
formatting.memory_divs | ||
) | ||
self.assertEqual(readable_units, "-29 Kb") | ||
|
||
readable_units = formatting._readable_units( | ||
1024, | ||
formatting.memory_divs, | ||
plural_aware=True | ||
) | ||
self.assertEqual(readable_units, "1 K") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters