summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPetr Viktorin <pviktori@redhat.com>2013-06-26 17:39:11 +0200
committerPetr Viktorin <pviktori@redhat.com>2013-07-15 15:49:15 +0200
commit0db6fb9ec51f7cd1b4fc29a5e1a13cd3fe7657e1 (patch)
tree9f99be22973fc0c44097fe2936c1238021407735
parentc47f3154be16a096b2d255c654e2277954b14833 (diff)
downloadfreeipa-0db6fb9ec51f7cd1b4fc29a5e1a13cd3fe7657e1.tar.gz
freeipa-0db6fb9ec51f7cd1b4fc29a5e1a13cd3fe7657e1.tar.xz
freeipa-0db6fb9ec51f7cd1b4fc29a5e1a13cd3fe7657e1.zip
BeakerLib plugin: Log http links in test docstrings
The main case for this is having ticket numbers in the Beaker ouput.
-rw-r--r--ipatests/beakerlib_plugin.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/ipatests/beakerlib_plugin.py b/ipatests/beakerlib_plugin.py
index 7c27c1650..97fd2c788 100644
--- a/ipatests/beakerlib_plugin.py
+++ b/ipatests/beakerlib_plugin.py
@@ -24,6 +24,7 @@ import subprocess
import traceback
import logging
import tempfile
+import re
import nose
from nose.plugins import Plugin
@@ -31,6 +32,8 @@ from nose.plugins import Plugin
from ipapython import ipautil
from ipapython.ipa_log_manager import log_mgr
+LINK_RE = re.compile(r'https?://[^\s]+')
+
class BeakerLibLogHandler(logging.Handler):
def __init__(self, beakerlib_command):
@@ -107,6 +110,10 @@ class BeakerLibPlugin(Plugin):
self.bash.stdin.flush()
assert self.bash.returncode is None, "BeakerLib Bash process exited"
+ def log_links(self, docstring):
+ for match in LINK_RE.finditer(docstring or ''):
+ self.log.info('Link: %s', match.group())
+
def report(self, stream):
"""End the Bash process"""
self.run_beakerlib_command(['exit'])
@@ -129,6 +136,7 @@ class BeakerLibPlugin(Plugin):
context.__name__, caption)
self.run_beakerlib_command(['rlPhaseStart', 'FAIL', phase_name])
self._in_class_setup = True
+ self.log_links(docstring)
def stopContext(self, context):
"""End a test context"""
@@ -148,6 +156,11 @@ class BeakerLibPlugin(Plugin):
phase_name = "%s: %s" % (test.id().replace('.', '-'), caption)
self.run_beakerlib_command(['rlPhaseStart', 'FAIL', phase_name])
+ while hasattr(test, 'test'):
+ # Un-wrap Nose test cases to get at the actual test method
+ test = test.test
+ self.log_links(getattr(test, '__doc__', ''))
+
def stopTest(self, test):
"""End a test phase"""
self.collect_logs(test.context)