Anonymous avatar Anonymous committed 4504c0b

Cleaned up.

Comments (0)

Files changed (2)

 import logging
 def pytest_addoption(parser):
+    """Adds options to py.test for controlling log capturing."""
     group = parser.getgroup('general')
 def pytest_runtest_setup(item):
+    """Start capturing log messages for this test."""
     if item.config.getvalue('capturelog'):
+        # Create a logging handler for this test.
         item.capturelog_stream =
         item.capturelog_handler = logging.StreamHandler(item.capturelog_stream)
         item.capturelog_formatter = logging.Formatter('%(asctime)s %(levelname)-8s: %(message)s')
+        # Attach the logging handler to the root logger.
         root_logger = logging.getLogger()
 def pytest_runtest_teardown(item):
+    """Stop capturing log messages for this test."""
     if item.config.getvalue('capturelog'):
+        # Detach the logging handler from the root logger.
 def pytest_runtest_makereport(__multicall__, item, call):
+    """Add captured log messages for this report."""
     report = __multicall__.execute()
     if item.config.getvalue('capturelog'):
+        # For failed tests that have captured log messages add a
+        # captured log section to the report.
         if not report.passed:
             longrepr = getattr(report, 'longrepr', None)
             if hasattr(longrepr, 'addsection'):
 import setuptools
-                 version='0.1',
+                 version='0.2',
                  description='py.test plugin to capture log messages',
                  author='Meme Dough',
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.