def test_log_get_set_output_function(self): logentries = [] def __log(userdata, category, priority, message): logentries.append((userdata, category, priority, message,)) # setUp should have set our output function already. origfunc, origdata = log.log_get_output_function() self.assertIsNone(origdata) logcount = len(self.logdata) origfunc(None, 0, 0, b"test_log_get_set_output_function") self.assertEqual(len(self.logdata), logcount + 1) self.assertEqual(self.logdata[logcount][3], b"test_log_get_set_output_function") logptr = log.SDL_LogOutputFunction(__log) log.log_set_output_function(logptr, "Testobject") ptr, userdata = log.log_get_output_function() self.assertEqual(userdata, "Testobject") log.log("output test") self.assertEqual(logentries[0], ("Testobject", log.SDL_LOG_CATEGORY_APPLICATION, log.SDL_LOG_PRIORITY_INFO, b"output test")) log.log_set_output_function(origfunc, userdata)
def test_log(self): self.logdata = [] # reset the log log.log("test") self.assertEqual(self.logdata[0], (None, log.SDL_LOG_CATEGORY_APPLICATION, log.SDL_LOG_PRIORITY_INFO, b"test")) log.log("abcdeghijk") self.assertEqual(self.logdata[1], (None, log.SDL_LOG_CATEGORY_APPLICATION, log.SDL_LOG_PRIORITY_INFO, b"abcdeghijk")) log.log(None) self.assertEqual(self.logdata[2], (None, log.SDL_LOG_CATEGORY_APPLICATION, log.SDL_LOG_PRIORITY_INFO, b"None")) log.log(123456) self.assertEqual(self.logdata[3], (None, log.SDL_LOG_CATEGORY_APPLICATION, log.SDL_LOG_PRIORITY_INFO, b"123456"))