So, here's a little test case to use in Django 1.8:
import logging
from django.test import TestCase
class LoggingTest(TestCase):
def test_logging(self):
with self.assertLogs(logging.getLogger('irk'), logging.INFO):
logging.getLogger('irk').warning('test')
Now, what can go wrong with it? I want to check if something is logged and the only thing that I do is log something. The 'irk' logger is set to level 20 (INFO), but still I get:
======================================================================
FAIL: test_logging (core.tests.JsonDecoratorTests)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/vagrant/irka2/irk/core/tests.py", line 279, in test_logging
logging.getLogger('irk').warning('test')
AssertionError: no logs of level INFO or higher triggered on irk
Any ideas what's wrong with this test case? Changing getLogger('irk')
to getLogger()
doesn't make any difference.
I'm using Django 1.8 and Python 3.4.
Aucun commentaire:
Enregistrer un commentaire