Source

south / south / tests / logger.py

Diff from to

File south/tests/logger.py

+import logging
 import os
+import tempfile
 import unittest
-import tempfile
+import StringIO
+import sys
 
 from django.conf import settings
 from django.db import connection, models
         self.test_path = tempfile.mkstemp(suffix=".south.log")[1]
     
     def test_db_execute_logging_nofile(self):
-        "Does logging degrade nicely if SOUTH_DEBUG_ON not set?"
+        "Does logging degrade nicely if SOUTH_LOGGING_ON not set?"
         settings.SOUTH_LOGGING_ON = False     # this needs to be set to False
                                               # to avoid issues where other tests
                                               # set this to True. settings is shared
                                               # between these tests.
         db.create_table("test9", [('email_confirmed', models.BooleanField(default=False))])
-        
+
+    def test_db_execute_logging_off_with_basic_config(self):
+        """
+        Does the south logger avoid outputing debug information with
+        south logging turned off and python logging configured with
+        a basic config?"
+        """
+        settings.SOUTH_LOGGING_ON = False
+
+        # Set root logger to capture WARNING and worse
+        logging_stream = StringIO.StringIO()
+        logging.basicConfig(stream=logging_stream, level=logging.WARNING)
+
+        db.create_table("test12", [('email_confirmed', models.BooleanField(default=False))])
+
+        # since south logging is off, and our root logger is at WARNING
+        # we should not find DEBUG info in the log
+        self.assertIs(logging_stream.getvalue(), '')
+
     def test_db_execute_logging_validfile(self):
         "Does logging work when passing in a valid file?"
         settings.SOUTH_LOGGING_ON = True
             [('email_confirmed', models.BooleanField(default=False))],
         )
         
-        
+