views:

48

answers:

3

I utilize the standard python logging module. When I call python manage.py test I'd like to disable logging before all the tests are ran. Is there a signal or some other kind of hook I could use to call logging.disable? Or is there some other way to disable logging when python manage.py test is ran?

+1  A: 

The only way I know of is to edit manage.py itself... not very elegant, of course, but at least it should get you to where you need to be.

Alex Martelli
Ah, I hadn't thought of that (...well obviously). Thanks!
Eric Palakovich Carr
@Eric, you're welcome!
Alex Martelli
+1  A: 

I patched test_extensions to also do this.

Matthew Schinckel
+1  A: 

As an easy alternative, you can disable logging when running tests in your settings file like this:

if 'test' in sys.argv:
    logger.removeHandler(handler)
    logger.setLevel(logging.ERROR)
Dick