forked from rlisagor/freshen
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'oesmith/pretty_nose_output'
- Loading branch information
Showing
5 changed files
with
262 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
Feature: Error steps | ||
In order to speed up development | ||
It is useful to see a verbose report of which step has failed | ||
|
||
Scenario: Error steps | ||
When I run nose -v --tags @one --error-steps examples/self_test | ||
Then it should fail with | ||
""" | ||
Sample: Missing ... UNDEFINED: "missing" # examples{sep}self_test{sep}features{sep}sample.feature:7 | ||
Sample: Passing ... ok | ||
Sample: Failing ... ERROR | ||
====================================================================== | ||
ERROR: Sample: Failing | ||
---------------------------------------------------------------------- | ||
Traceback (most recent call last): | ||
File "{cwd}{sep}examples{sep}self_test{sep}features{sep}steps.py", line 14, in failing | ||
flunker() | ||
File "{cwd}{sep}examples{sep}self_test{sep}features{sep}steps.py", line 5, in flunker | ||
raise Exception("FAIL") | ||
Exception: FAIL | ||
[36m@one[0m | ||
Feature: Sample | ||
[36m@four[0m | ||
Scenario: Failing | ||
[31mgiven failing [0m [2m# examples{sep}self_test{sep}features{sep}sample.feature:18[0m | ||
---------------------------------------------------------------------- | ||
Ran 3 tests in {time} | ||
FAILED (UNDEFINED=1, errors=1) | ||
""" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
Feature: List undefined steps | ||
In order to speed up development | ||
It is useful to see a report of undefined steps encountered in a test run | ||
|
||
Scenario: List undefined | ||
When I run nose -v --tags @one --list-undefined examples/self_test | ||
Then it should fail with | ||
""" | ||
Sample: Missing ... UNDEFINED: "missing" # examples{sep}self_test{sep}features{sep}sample.feature:7 | ||
Sample: Passing ... ok | ||
Sample: Failing ... ERROR | ||
====================================================================== | ||
ERROR: Sample: Failing | ||
---------------------------------------------------------------------- | ||
Traceback (most recent call last): | ||
File "{cwd}{sep}examples{sep}self_test{sep}features{sep}steps.py", line 14, in failing | ||
flunker() | ||
File "{cwd}{sep}examples{sep}self_test{sep}features{sep}steps.py", line 5, in flunker | ||
raise Exception("FAIL") | ||
Exception: FAIL | ||
>> in "failing" # examples{sep}self_test{sep}features{sep}sample.feature:18 | ||
====================================================================== | ||
Tests with undefined steps | ||
---------------------------------------------------------------------- | ||
[36m@one[0m | ||
Feature: Sample | ||
[36m@two @three[0m | ||
Scenario: Missing | ||
[33mgiven missing [0m [2m# examples{sep}self_test{sep}features{sep}sample.feature:7[0m | ||
You can implement step definitions for the missing steps with these snippets: | ||
@Given(r"^missing$") | ||
def given_missing(): | ||
# code here | ||
---------------------------------------------------------------------- | ||
Ran 3 tests in {time} | ||
FAILED (UNDEFINED=1, errors=1) | ||
""" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,73 +1,33 @@ | ||
#-*- 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 | ||
from freshen.prettyprint import FreshenPrettyPrint | ||
|
||
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 FreshenPrettyPrint.feature(feature) | ||
|
||
def before_scenario(self, scenario): | ||
if scenario.tags: | ||
print ' ' + colored(" ".join(('@' + t) for t in scenario.tags), TAG) | ||
print " Scenario:", scenario.name | ||
print FreshenPrettyPrint.scenario(scenario) | ||
|
||
def after_scenario(self, scenario): | ||
|
||
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) | ||
print FreshenPrettyPrint.step_failed(step) | ||
|
||
def step_ambiguous(self, step, e): | ||
self._step(step, AMBIGUOUS) | ||
print FreshenPrettyPrint.step_ambiguous(step) | ||
|
||
def step_undefined(self, step, e): | ||
self._step(step, UNDEFINED) | ||
print FreshenPrettyPrint.step_undefined(step) | ||
|
||
def step_exception(self, step, e): | ||
self._step(step, ERROR) | ||
print FreshenPrettyPrint.step_exception(step) | ||
|
||
def after_step(self, step): | ||
self._step(step, PASSED) | ||
print FreshenPrettyPrint.step_passed(step) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.