libcloud-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From to...@apache.org
Subject [libcloud] 01/02: Fix failing test - make sure we correctly 0 pad all the values < 10.
Date Sun, 11 Oct 2020 16:04:58 GMT
This is an automated email from the ASF dual-hosted git repository.

tomaz pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/libcloud.git

commit f6d6e0613539dd3a3b474a2c79675ba8a5071502
Author: Tomaz Muraus <tomaz@tomaz.me>
AuthorDate: Sun Oct 11 15:35:00 2020 +0200

    Fix failing test - make sure we correctly 0 pad all the values < 10.
---
 libcloud/test/dns/test_base.py | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/libcloud/test/dns/test_base.py b/libcloud/test/dns/test_base.py
index c1a8d27..1ceba05 100644
--- a/libcloud/test/dns/test_base.py
+++ b/libcloud/test/dns/test_base.py
@@ -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())


Mime
View raw message