changeset 86:1cd67680c38c

Ability to output debug logging to `stdout` when running unit-tests.
author Ludovic Chabant <ludovic@chabant.com>
date Wed, 03 Sep 2014 17:28:10 -0700
parents 3471ffa059b2
children 2fb6501ed668
files tests/conftest.py
diffstat 1 files changed, 19 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/conftest.py	Wed Sep 03 17:28:10 2014 -0700
@@ -0,0 +1,19 @@
+import sys
+import logging
+
+
+def pytest_runtest_setup(item):
+    pass
+
+
+def pytest_addoption(parser):
+    parser.addoption('--log-debug', action='store_true',
+            help="Sets the PieCrust logger to output debug info to stdout.")
+
+
+def pytest_configure(config):
+    if config.getoption('--log-debug'):
+        hdl = logging.StreamHandler(stream=sys.stdout)
+        logging.getLogger('piecrust').addHandler(hdl)
+        logging.getLogger('piecrust').setLevel(logging.DEBUG)
+