Esempio n. 1
0
    def test_close_files(self):
        class F(object):
            closed = 0
            def close(self):
                self.closed += 1
        f = F()
        def wr():
            return f

        loghandler._reopenable_handlers.append(wr)
        loghandler.closeFiles()
        loghandler.closeFiles()

        self.assertEqual(1, f.closed)
Esempio n. 2
0
    def tearDown(self):
        logging.root.manager.loggerDict.clear()
        logging.root.manager.loggerDict.update(self._old_logger_dict)

        for h in self._old_logger.handlers:
            self._old_logger.removeHandler(h)
        for h in self._old_handlers:
            self._old_logger.addHandler(h)
        self._old_logger.setLevel(self._old_level)

        while self._created:
            os.unlink(self._created.pop())

        self.assertEqual(loghandler._reopenable_handlers, [])
        loghandler.closeFiles()
        loghandler._reopenable_handlers == []
Esempio n. 3
0
    def tearDown(self):
        logging.root.manager.loggerDict.clear()
        logging.root.manager.loggerDict.update(self._old_logger_dict)

        for h in self._old_logger.handlers:
            self._old_logger.removeHandler(h)
        for h in self._old_handlers:
            self._old_logger.addHandler(h)
        self._old_logger.setLevel(self._old_level)

        while self._created:
            os.unlink(self._created.pop())

        self.assertEqual(loghandler._reopenable_handlers, [])
        loghandler.closeFiles()
        loghandler._reopenable_handlers == []
Esempio n. 4
0
    def test_close_files(self):
        class F(object):
            closed = 0

            def close(self):
                self.closed += 1

        f = F()

        def wr():
            return f

        loghandler._reopenable_handlers.append(wr)
        loghandler.closeFiles()
        loghandler.closeFiles()

        self.assertEqual(1, f.closed)