1. youngking
  2. kahgean

Commits

Can Xue  committed 3866de9

some update

  • Participants
  • Parent commits dc4b82a
  • Branches default

Comments (0)

Files changed (3)

File kahgean/logkit.py

View file
 
 
 def append_options(options):
-    """work with kahgean.options, add arguments to an ``Options`` object"""
+    """work with ``kahgean.options``, append arguments to the given
+    ``Options`` object"""
     options.add_option('--log-level', help='logging level (default: info)')
     options.add_option('--log-format', help='')
     options.add_option('--log-date-format', help='')
 
 def deal_with_options(options, clear_handlers=True):
     """work with ``append_options()``, deal with the parsing result of
-    the ``Options`` object"""
+    the ``options`` object"""
     root_logger = logging.getLogger()
     # remove all hanlers
     if clear_handlers:

File test/test_logkit.py

View file
 from kahgean.options import Options
 
 
+TEST_SERVER_PORT = DEFAULT_TCP_LOGGING_PORT + 10000
+
+
 def setup_module():
     global options
     options = Options()
 def test_no_options():
     options.parse_options([])
     logkit.deal_with_options(options)
+    sys.stderr.write('\n')
     logging.debug('You should not see this')
     logging.info('this is an info')
     logging.warning('this is a warning')
     global logserver, registry
     registry = list()
     logserver = SocketServer.TCPServer(
-        ('localhost', DEFAULT_TCP_LOGGING_PORT + 10000),
+        ('localhost', TEST_SERVER_PORT),
         LogRecordStreamHandler)
     thread.start_new_thread(logserver.serve_forever, ())
 
 @with_setup(prepare_logserver)
 def test_logserver():
     options.parse_options(['--log-level', 'warning', '--log-server',
-                           'localhost:%d' % (DEFAULT_TCP_LOGGING_PORT + 10000)])
+                           'localhost:%d' % TEST_SERVER_PORT])
     logkit.deal_with_options(options)
     logging.debug('debug')
     logging.info('info')

File test/test_options.py

View file
 
 
 def prepare_unaccptable():
-    class Nul(object):
-        def write(*args):
-            pass
     global stderr
     stderr = sys.stderr
-    sys.stderr = Nul()
+    sys.stderr = open(os.devnull, 'w+')
 
 
 def cleanup_unaccptable():