[py-svn] py-trunk commit 381509aaa6ad: add capturelog generated plugin text
commits-noreply at bitbucket.org
commits-noreply at bitbucket.org
Mon Apr 19 14:44:36 CEST 2010
# HG changeset patch -- Bitbucket.org
# Project py-trunk
# URL http://bitbucket.org/hpk42/py-trunk/overview
# User holger krekel <holger at merlinux.eu>
# Date 1271681051 -7200
# Node ID 381509aaa6ad365614974fdd1f10494a53c953a8
# Parent 97558e665d8700a2be673b98c3fa927528401e11
add capturelog generated plugin text
--- /dev/null
+++ b/doc/test/plugin/capturelog.txt
@@ -0,0 +1,86 @@
+
+capture output of logging module.
+=================================
+
+
+.. contents::
+ :local:
+
+Installation
+------------
+
+You can install the `pytest-capturelog pypi`_ package
+with pip::
+
+ pip install pytest-capturelog
+
+or with easy install::
+
+ easy_install pytest-capturelog
+
+.. _`pytest-capturelog pypi`: http://pypi.python.org/pypi/pytest-capturelog/
+
+Usage
+-----
+
+If the plugin is installed log messages are captured by default and for
+each failed test will be shown in the same manner as captured stdout and
+stderr.
+
+Running without options::
+
+ py.test test_capturelog.py
+
+Shows failed tests like so::
+
+ -------------------------- Captured log ---------------------------
+ test_capturelog.py 26 INFO text going to logger
+ ------------------------- Captured stdout -------------------------
+ text going to stdout
+ ------------------------- Captured stderr -------------------------
+ text going to stderr
+ ==================== 2 failed in 0.02 seconds =====================
+
+By default each captured log message shows the module, line number,
+log level and message. Showing the exact module and line number is
+useful for testing and debugging. If desired the log format and date
+format can be specified to anything that the logging module supports.
+
+Running pytest specifying formatting options::
+
+ py.test --log-format="%(asctime)s %(levelname)s %(message)s" --log-date-format="%Y-%m-%d %H:%M:%S" test_capturelog.py
+
+Shows failed tests like so::
+
+ -------------------------- Captured log ---------------------------
+ 2010-04-10 14:48:44 INFO text going to logger
+ ------------------------- Captured stdout -------------------------
+ text going to stdout
+ ------------------------- Captured stderr -------------------------
+ text going to stderr
+ ==================== 2 failed in 0.02 seconds =====================
+
+Further it is possible to disable capturing of logs completely with::
+
+ py.test --nocapturelog test_capturelog.py
+
+Shows failed tests in the normal manner as no logs were captured::
+
+ ------------------------- Captured stdout -------------------------
+ text going to stdout
+ ------------------------- Captured stderr -------------------------
+ text going to stderr
+ ==================== 2 failed in 0.02 seconds =====================
+
+command line options
+--------------------
+
+
+``--nocapturelog``
+ disable log capture
+``--log-format=LOG_FORMAT``
+ log format as used by the logging module
+``--log-date-format=LOG_DATE_FORMAT``
+ log date format as used by the logging module
+
+.. include:: links.txt
More information about the pytest-commit
mailing list