(self)
| 44 | ) |
| 45 | |
| 46 | def setUp(self): |
| 47 | self.formatter = LogFormatter(color=False) |
| 48 | # Fake color support. We can't guarantee anything about the $TERM |
| 49 | # variable when the tests are run, so just patch in some values |
| 50 | # for testing. (testing with color off fails to expose some potential |
| 51 | # encoding issues from the control characters) |
| 52 | self.formatter._colors = {logging.ERROR: u"\u0001"} |
| 53 | self.formatter._normal = u"\u0002" |
| 54 | # construct a Logger directly to bypass getLogger's caching |
| 55 | self.logger = logging.Logger("LogFormatterTest") |
| 56 | self.logger.propagate = False |
| 57 | self.tempdir = tempfile.mkdtemp() |
| 58 | self.filename = os.path.join(self.tempdir, "log.out") |
| 59 | self.handler = self.make_handler(self.filename) |
| 60 | self.handler.setFormatter(self.formatter) |
| 61 | self.logger.addHandler(self.handler) |
| 62 | |
| 63 | def tearDown(self): |
| 64 | self.handler.close() |
no test coverage detected