diff --git a/avocado/utils/data_structures.py b/avocado/utils/data_structures.py index 2e5e737265fc11dcb10afb435338cd65a00cc5c8..bff729574d6da9c1b131154e9949b30b90c439fd 100644 --- a/avocado/utils/data_structures.py +++ b/avocado/utils/data_structures.py @@ -297,8 +297,8 @@ class DataSize(object): """ if attr not in self.MULTIPLIERS: raise AttributeError('Attribute %s does not exist.' % attr) - return (self.value * self.MULTIPLIERS[self.unit] / - self.MULTIPLIERS[attr]) + return int(self.value * self.MULTIPLIERS[self.unit] / + self.MULTIPLIERS[attr]) def __dir__(self): """ diff --git a/selftests/unit/test_data_structures.py b/selftests/unit/test_data_structures.py index d39767641d9e31f4bbf7a1efe08822e9eb1dd99b..76c32e77905074b85c64078d9e724259bb388daa 100644 --- a/selftests/unit/test_data_structures.py +++ b/selftests/unit/test_data_structures.py @@ -105,9 +105,11 @@ class TestDataSize(unittest.TestCase): self.assertRaises(data_structures.InvalidDataSize, data_structures.DataSize, '10Mb') + def test_value_and_type(self): + self.assertIs(data_structures.DataSize('0b').b, 0) + self.assertIs(data_structures.DataSize('0t').b, 0) + def test_values(self): - self.assertEqual(data_structures.DataSize('0b').b, 0) - self.assertEqual(data_structures.DataSize('0t').b, 0) self.assertEqual(data_structures.DataSize('10m').b, 10485760) self.assertEqual(data_structures.DataSize('10M').b, 10485760)