Skip to content

Commit 9e9f2ed

Browse files
author
a good root :)
committed
show the name of the failed test and add some color to the output
1 parent c767eca commit 9e9f2ed

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

pytest_dependency.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88
import pytest
99

1010
__version__ = "0.2"
11+
from blessings import Terminal
1112

13+
terminal = Terminal()
1214

1315
class DependencyItemStatus(object):
1416
"""Status of a test item in a dependency manager.
@@ -59,10 +61,13 @@ def addResult(self, item, marker, rep):
5961
status = self.results.setdefault(name, DependencyItemStatus())
6062
status.addResult(rep)
6163

62-
def checkDepend(self, depends):
64+
def checkDepend(self, depends, item):
6365
for i in depends:
6466
if not(i in self.results and self.results[i].isSuccess()):
65-
pytest.skip("depends on %s" % i)
67+
msg = "%s depends on %s %s" % (terminal.yellow(item.name),
68+
terminal.yellow(i),
69+
terminal.red('(failed)'))
70+
pytest.skip(msg)
6671

6772

6873
def depends(request, other):
@@ -84,7 +89,7 @@ def depends(request, other):
8489
"""
8590
item = request.node
8691
manager = DependencyManager.getManager(item)
87-
manager.checkDepend(other)
92+
manager.checkDepend(other, item)
8893

8994

9095
@pytest.hookimpl(tryfirst=True, hookwrapper=True)
@@ -108,4 +113,4 @@ def pytest_runtest_setup(item):
108113
depends = marker.kwargs.get('depends')
109114
if depends:
110115
manager = DependencyManager.getManager(item)
111-
manager.checkDepend(depends)
116+
manager.checkDepend(depends, item)

0 commit comments

Comments
 (0)