mirror of
https://github.com/spalencsar/bearhub.git
synced 2026-07-06 21:44:16 +02:00
[commons.util] refactoring: always strips unit string in 'size_to_byte'
This commit is contained in:
@@ -29,7 +29,7 @@ def deep_update(source: dict, overrides: dict):
|
||||
|
||||
|
||||
def size_to_byte(size: Union[float, int, str], unit: str, logger: Optional[Logger] = None) -> Optional[float]:
|
||||
lower_unit = unit.lower()
|
||||
lower_unit = unit.strip().lower()
|
||||
|
||||
if isinstance(size, str):
|
||||
try:
|
||||
|
||||
@@ -41,4 +41,4 @@ class SizeToByteTest(TestCase):
|
||||
self.assertEqual(6383852471797678, size_to_byte('5.67', 'P'))
|
||||
|
||||
def test_must_treat_string_sizes_before_converting(self):
|
||||
self.assertEqual(58675.2, size_to_byte(' 57 , 3 ', 'K'))
|
||||
self.assertEqual(58675.2, size_to_byte(' 57 , 3 ', ' K '))
|
||||
|
||||
Reference in New Issue
Block a user