PyDev unittesting: How to capture text logged to a logging.Logger in "Captured Output"
I am using PyDev for development and unit-testing of my python application.
As for unit-testing, everything works great behalf the fact that content logged to any logging.Logger is not captured by the "Captured output" of pydev...

I already forward everything logged to the standard output like this:

<!-- language: lang-py -->

    import sys
    logger = logging.getLogger()
    logger.level = logging.DEBUG
    logger.addHandler(logging.StreamHandler(sys.stdout))

... nevertheless the "Captured output" does not display stuff logged to loggers.

Here an example unittest-script: test.py
<!-- language: lang-py -->

    import sys
    import unittest
    import logging
    
    logger = logging.getLogger()
    logger.level = logging.DEBUG
    logger.addHandler(logging.StreamHandler(sys.stdout))
        
    class TestCase(unittest.TestCase):
        def testSimpleMsg(self):
            print("AA")
            logging.getLogger().info("BB")

The Console output is:

    Finding files... done.
    Importing test modules ... done.
    
    testSimpleMsg (itf.lowlevel.tests.hl7.TestCase) ... AA
    2011-09-19 16:48:00,755 - root - INFO - BB
    BB
    ok
    
    ----------------------------------------------------------------------
    Ran 1 test in 0.001s
    
    OK

But the **CAPTURED OUTPUT** for the test is:

    ======================== CAPTURED OUTPUT =========================
    AA

Does anybody knows how to capture everything is logged to a logging.Logger during the execution of this test?

Best thanks,
gecco

PyDev unittesting: How to capture text logged to a logging.Logger in "Captured Output"
===

I am using PyDev for development and unit-testing of my python application.
As for unit-testing, everything works great behalf the fact that content logged to any logging.Logger is not captured by the "Captured output" of pydev...

I already forward everything logged to the standard output like this:

<!-- language: lang-py -->

    import sys
    logger = logging.getLogger()
    logger.level = logging.DEBUG
    logger.addHandler(logging.StreamHandler(sys.stdout))

... nevertheless the "Captured output" does not display stuff logged to loggers.

Here an example unittest-script: test.py
<!-- language: lang-py -->

    import sys
    import unittest
    import logging
    
    logger = logging.getLogger()
    logger.level = logging.DEBUG
    logger.addHandler(logging.StreamHandler(sys.stdout))
        
    class TestCase(unittest.TestCase):
        def testSimpleMsg(self):
            print("AA")
            logging.getLogger().info("BB")

The Console output is:

    Finding files... done.
    Importing test modules ... done.
    
    testSimpleMsg (itf.lowlevel.tests.hl7.TestCase) ... AA
    2011-09-19 16:48:00,755 - root - INFO - BB
    BB
    ok
    
    ----------------------------------------------------------------------
    Ran 1 test in 0.001s
    
    OK

But the **CAPTURED OUTPUT** for the test is:

    ======================== CAPTURED OUTPUT =========================
    AA

Does anybody knows how to capture everything is logged to a logging.Logger during the execution of this test?

Best thanks,
gecco
