[commons.util] refactoring: always strips unit string in 'size_to_byte'

This commit is contained in:
Vinicius Moreira
2022-04-06 10:44:42 -03:00
parent 47cb969f1a
commit 887ae2da5c
2 changed files with 2 additions and 2 deletions

View File

@@ -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]: 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): if isinstance(size, str):
try: try:

View File

@@ -41,4 +41,4 @@ class SizeToByteTest(TestCase):
self.assertEqual(6383852471797678, size_to_byte('5.67', 'P')) self.assertEqual(6383852471797678, size_to_byte('5.67', 'P'))
def test_must_treat_string_sizes_before_converting(self): 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 '))