Fix failing test - make sure we correctly 0 pad all the values < 10.
@@ -94,8 +94,11 @@ class BaseTestCase(unittest.TestCase):
lines2 = content.split('\n')
now = datetime.datetime.now()
- date_str = "%s-%s-%s %s:%s:%s" % (now.year, now.month, now.day, now.hour, now.minute,
- now.second)
+ date_str = "%s-%s-%s %s:%s:%s" % (now.year, zero_pad(now.month),
+ zero_pad(now.day),
+ zero_pad(now.hour),
+ zero_pad(now.minute),
+ zero_pad(now.second))
expected_header = "; Generated by Libcloud v%s on %s" % (__version__, date_str)
self.assertEqual(lines1[0], expected_header)
@@ -142,5 +145,12 @@ class BaseTestCase(unittest.TestCase):
self.assertEqual(result, '')
+def zero_pad(value: int) -> str:
+ if value < 10:
+ return "0" + str(value)
+
+ return str(value)
+
+
if __name__ == '__main__':
sys.exit(unittest.main())
