Пример #1
0
    def test_get_filename(self):
        with TestAreaContext("python/res_log/log") as work_area:
            test_log_filename = "log_test_file.txt"
            ResLog.init(1, test_log_filename, True)
            message = "This is fun"
            ResLog.log(1, message)

            self.assertEqual(ResLog.getFilename(), test_log_filename)
Пример #2
0
    def test_log(self):
        with TestAreaContext("python/res_log/log") as work_area:
            test_log_filename = "test_log"
            ResLog.init(1, test_log_filename, True)
            message = "This is fun"
            ResLog.log(1, message)

            self.assertTrue(os.path.isfile(test_log_filename))

            with open(test_log_filename, "r") as f:
                text = f.readlines()
                self.assertTrue(len(text) > 0)
                self.assertTrue(message in text[-1])
Пример #3
0
 def test_init_perm_denied(self):
     with TestAreaContext("python/res_log"):
         os.mkdir("read_only")
         os.chmod("read_only", 0o500)
         with self.assertRaises(IOError):
             ResLog.init(1, "read_only/logfile.txt", True)