Logo Search packages:      
Sourcecode: magicicada version File versions  Download package

helpers.py

# Helpers for the tessts
#
# Author: Facundo Batista <facundo@taniquetil.com.ar>
#
# Copyright 2010 Chicharreros
#
# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 3, as published
# by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranties of
# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
# PURPOSE.  See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program.  If not, see <http://www.gnu.org/licenses/>.

"""Helpers for the tests."""

import logging


00024 class MementoHandler(logging.Handler):
    """A handler class which store logging records in a list."""

00027     def __init__(self, *args, **kwargs):
        """Create the instance, and add a records attribute."""
        logging.Handler.__init__(self, *args, **kwargs)
        self.records = []

00032     def emit(self, record):
        """Just add the record to self.records."""
        self.records.append(record)

00036     def check(self, level, msg):
        """Check that something is logged."""
        for rec in self.records:
            if rec.levelname == level and rec.message == msg:
                return True
        return False

00043     def check_inf(self, msg):
        """Shortcut for INFO check."""
        return self.check('INFO', msg)

00047     def check_dbg(self, msg):
        """Shortcut for DEBUG check."""
        return self.check('DEBUG', msg)

Generated by  Doxygen 1.6.0   Back to index