/usr/share/pyshared/freshen/handlers.py is in python-freshen 0.2-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 | #-*- coding: utf8 -*-
from freshen.cuke import FreshenHandler
import sys
import traceback
COLORS = {
'bold': '1',
'grey': '2',
'underline': '4',
'red': '31',
'green': '32',
'yellow': '33',
'blue': '34',
'magenta': '35',
'cyan': '36',
'white': '37'
}
UNDEFINED = 'yellow'
AMBIGUOUS = 'cyan'
FAILED = 'red'
ERROR = 'red,bold'
PASSED = 'green'
TAG = 'cyan'
COMMENT = 'grey'
def colored(text, colorspec):
colors = [c.strip() for c in colorspec.split(',')]
result = ""
for c in colors:
result += "\033[%sm" % COLORS[c]
result += text + "\033[0m"
return result
class ConsoleHandler(FreshenHandler):
def before_feature(self, feature):
if feature.tags:
print colored(" ".join(('@' + t) for t in feature.tags), TAG)
print 'Feature:', feature.name
if feature.description != ['']:
print "\n".join((' ' + l) for l in feature.description)
print
def before_scenario(self, scenario):
if scenario.tags:
print ' ' + colored(" ".join(('@' + t) for t in scenario.tags), TAG)
print " Scenario:", scenario.name
def after_scenario(self, scenario):
print
def _step(self, step, color):
print " " + colored('%-40s' % (step.step_type + " " + step.match), color) + \
colored(" # " + step.source_location(), COMMENT)
def step_failed(self, step, e):
self._step(step, FAILED)
def step_ambiguous(self, step, e):
self._step(step, AMBIGUOUS)
def step_undefined(self, step, e):
self._step(step, UNDEFINED)
def step_exception(self, step, e):
self._step(step, ERROR)
def after_step(self, step):
self._step(step, PASSED)
|