refine printing of exceptions via the pluginmanager.

if there is no pytest_internalerror() hook acknowledging
receival we print the exception to sys.stderr.  This helps
to see issues when there are failures in TerminalReporter
initialization.

--HG--
branch : trunk
This commit is contained in:
holger krekel
2010-10-05 17:21:41 +02:00
parent a054b63bac
commit cebcdb83cf
4 changed files with 22 additions and 2 deletions

View File

@@ -214,6 +214,21 @@ class TestBootstrapping:
for name in 'xyz', 'pytest_xyz', 'pytest_Xyz', 'Xyz':
impname = canonical_importname(name)
def test_notify_exception(self, capfd):
pp = PluginManager()
excinfo = py.test.raises(ValueError, "raise ValueError(1)")
pp.notify_exception(excinfo)
out, err = capfd.readouterr()
assert "ValueError" in err
class A:
def pytest_internalerror(self, excrepr):
return True
pp.register(A())
pp.notify_exception(excinfo)
out, err = capfd.readouterr()
assert not err
class TestPytestPluginInteractions:
def test_addhooks_conftestplugin(self, testdir):