← Back to team overview

yahoo-eng-team team mailing list archive

[Bug 1413805] [NEW] capture text logged in integration tests to a file

 

Public bug reported:

 the unittest2 runner replaces sys.stdout/sys.stderr before the testing
starts, and the StreamHandler is still writing to the original
sys.stdout.

To assign the 'current' sys.stdout to the handler


import sys
import unittest
import logging

logger = logging.getLogger()
logger.level = logging.DEBUG

class TestCase(unittest.TestCase):
    def Setup(self):
        //stream_handler = logging.StreamHandler(sys.stdout)
        self.handler =  logging.StreamHandler(sys.stdout)
        logger.addHandler(stream_handler)
        
  def Teardown()
        logger.removeHandler(stream_handler)

** Affects: horizon
     Importance: Undecided
         Status: New


** Tags: integration-tests

** Tags added: integration-tests

-- 
You received this bug notification because you are a member of Yahoo!
Engineering Team, which is subscribed to OpenStack Dashboard (Horizon).
https://bugs.launchpad.net/bugs/1413805

Title:
  capture text logged  in integration tests to a file

Status in OpenStack Dashboard (Horizon):
  New

Bug description:
   the unittest2 runner replaces sys.stdout/sys.stderr before the
  testing starts, and the StreamHandler is still writing to the original
  sys.stdout.

  To assign the 'current' sys.stdout to the handler

  
  import sys
  import unittest
  import logging

  logger = logging.getLogger()
  logger.level = logging.DEBUG

  class TestCase(unittest.TestCase):
      def Setup(self):
          //stream_handler = logging.StreamHandler(sys.stdout)
          self.handler =  logging.StreamHandler(sys.stdout)
          logger.addHandler(stream_handler)
          
    def Teardown()
          logger.removeHandler(stream_handler)

To manage notifications about this bug go to:
https://bugs.launchpad.net/horizon/+bug/1413805/+subscriptions


Follow ups

References