Python: Let’s call “datetime”!
For QA engineer very often situation, when need keep test results created by scheduling. I would like to share with you, one very simple and the same time very powerfull tool. It’s calling “datetime”. This module will add timestamp inside your code. In your input you can see next attributes: date, time (hours, minutes, seconds and microseconds) and also timezone information if need. Also, for more fast align output files in you file browser you can include that information inside a name of created output file. Quick Example: [code language="python"] import datetime t = datetime.date.today() y = datetime.datetime.today() f = open(str(t) + ‘.datime.log’, ‘a’) # 'a' - will add new test results inside existing file. # Task a = 3 b = 3 c = a * b # Action f.write(‘\nData: ‘ + str(y)) f.write(‘\nResult: ‘ + str(c)) f.close() [/code] Output: Data: 2015-10-26 09:35:59.941000 Result: 9