From e876ad9abd880086aab15d4ed1c877fdfa67dcf8 Mon Sep 17 00:00:00 2001 From: Ronny Pfannschmidt Date: Wed, 22 Aug 2012 21:43:42 +0200 Subject: [PATCH] fix issue 179 - propperly show the dependency chain of factories on setup failure --- CHANGELOG | 2 ++ _pytest/python.py | 10 ++++++++-- testing/test_python.py | 8 +++++--- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 78c7e4f25..629e99199 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -35,6 +35,8 @@ Changes between 2.2.4 and 2.3.0.dev - fix issue128: show captured output when capsys/capfd are used +- fix issue179: propperly show the dependency chain of factories + - pluginmanager.register(...) now raises ValueError if the plugin has been already registered or the name is taken diff --git a/_pytest/python.py b/_pytest/python.py index 6e1841605..c67cafbdf 100644 --- a/_pytest/python.py +++ b/_pytest/python.py @@ -1211,8 +1211,14 @@ class FuncargLookupErrorRepr(TerminalRepr): def toterminal(self, tw): tw.line() - for line in self.factblines or []: - tw.line(line) + if self.factblines: + tw.line(' dependency of:') + for factorydef in self.factblines: + tw.line(' %s in %s' % ( + factorydef.argname, + factorydef.baseid, + )) + tw.line() for line in self.deflines: tw.line(" " + line.strip()) for line in self.errorstring.split("\n"): diff --git a/testing/test_python.py b/testing/test_python.py index a34a74191..c97810514 100644 --- a/testing/test_python.py +++ b/testing/test_python.py @@ -1664,8 +1664,7 @@ class TestFuncargFactory: "*2 passed*" ]) - @pytest.mark.xfail(reason="factorydef passed to tw.line") - def test_factory_uses_unknown_funcarg_error(self, testdir): + def test_factory_uses_unknown_funcarg_as_dependency_error(self, testdir): testdir.makepyfile(""" import pytest @@ -1682,7 +1681,10 @@ class TestFuncargFactory: """) result = testdir.runpytest() result.stdout.fnmatch_lines([ - "*LookupError: no factory found for argument 'missing'" + "*dependency of:*", + "*call_fail*", + "*def fail(*", + "*LookupError: no factory found for argument 'missing'", ])