def test_write (self): log = Logger("debug", self.tmp.name, "%(levelname)s [%(component)s]: %(message)s", False) c = Component() c.name = "Testing" log.write(c, "debug", "this is a debug message: %d", 1) log.write(c, "info", "this is a info message: %d", 2) log.write(c, "warning", "this is a warning message: %d", 3) log.write(c, "error", "this is a error message: %d", 4) log.write(c, "critical", "this is a critical message: %d", 5) self.tmp.flush() self.tmp.seek(0) output = self.tmp.read() self.assertEquals(output, expected_output.lstrip(), "got expected output")
def test_name(self): c = Component() self.assertEquals(c.name, "Component", "Component.name has a default") c.name = "TestComponent" self.assertEquals(c.name, "TestComponent", "Component.name can be set")