def test_raise_exception_upon_error_critical_log(self): '''Make sure exceptions are raised upon ERROR or CRITICAL log messages''' self.assertEqual(settings.RAISE_EXCEPTION_ON_ERROR, True, "To run the tests, RAISE_EXCEPTION_ON_ERROR must be set to True in the settings, otherwise some exceptions might go unnoticed") log = get_logger(__name__) exception_raised = False try: log.error('Test error log message') except: exception_raised = True self.assertEqual(exception_raised, True)
# # You should have received a copy of the GNU Affero General Public License # along with this program in a file in the toplevel directory called # "AGPLv3". If not, see <http://www.gnu.org/licenses/>. # # Includes ########################################################## from django.conf import settings import time # Logging ########################################################### from plebia.log import get_logger log = get_logger(__name__) # Functions ######################################################### def sane_text(text, length=0): '''Remove non-string characters from text, and optionally limit size to length characters (0 for no limit)''' if not isinstance(text, basestring): log.debug('Provided text is not a string "%s"', text) return '' # Make sure we use unicode strings sane_text = to_unicode(text) # HTML NULL entity