Disable south debug logging when testing apps with nose in django

If you’re testing your apps using django-nose and if you have the south database migration app installed, you will notice a high amount of debug messages in the terminal coming from south. This is because south itself sets the level of logging to debug. Unfortunately the south developers are currently not willing to change that.

To silence south, you can write a little nose-plugin, which sets the logging level of south from DEBUG to a level of your choice (e.g. ERROR). To achieve that, simply create a new python module containing the plugin:

nose_plugins.py:

from nose.plugins import Plugin
import logging

class SilenceSouth(Plugin):
    south_logging_level = logging.ERROR
    
    def configure(self, options, conf):
        super(SilenceSouth, self).configure(options, conf)
        logging.getLogger('south').setLevel(self.south_logging_level)

You can put nose_plugin.py anywhere in your project folder. In the second step you have to tell nose to use that plugin, and where it is located. To do this, simply add the following lines to the settings.py of your project:

settings.py

NOSE_PLUGINS = [
    '<your_project>.path.to.nose_plugins.SilenceSouth',
]

The result: no more annoying debug messages from south during testing.

Advertisements

3 thoughts on “Disable south debug logging when testing apps with nose in django

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s