Exemplo n.º 1
0
 def test_file_nonutc_iso_nonutctz(self):
     temp_logfile = tempfile.mkstemp()[1]
     file_logger = FileLogger({
         "filename": temp_logfile,
         "buffered": False,
         "dateformat": "iso8601",
         "tz": "Europe/Warsaw",
     })
     monitor = MonitorNull()
     monitor.run_test()
     file_logger.save_result2("null", monitor)
     self.assertTrue(os.path.exists(temp_logfile))
     with open(temp_logfile, "r") as fh:
         self.assertEqual(
             fh.readline().strip(),
             "2020-04-18 13:00:00+02:00 simplemonitor starting",
         )
         self.assertEqual(
             fh.readline().strip(),
             "2020-04-18 13:00:00+02:00 null: ok (0.000s)",
         )
     try:
         os.unlink(temp_logfile)
     except PermissionError:
         # Windows won't remove a file which is in use
         pass
Exemplo n.º 2
0
 def test_file_nonutc(self):
     temp_logfile = tempfile.mkstemp()[1]
     file_logger = FileLogger({"filename": temp_logfile, "buffered": False})
     monitor = MonitorNull()
     monitor.run_test()
     file_logger.save_result2("null", monitor)
     self.assertTrue(os.path.exists(temp_logfile))
     ts = str(int(time.time()))
     with open(temp_logfile, "r") as fh:
         self.assertEqual(fh.readline().strip(),
                          "{} simplemonitor starting".format(ts))
         self.assertEqual(fh.readline().strip(),
                          "{} null: ok (0.000s)".format(ts))
     try:
         os.unlink(temp_logfile)
     except PermissionError:
         # Windows won't remove a file which is in use
         pass