[Pytest-commit] Issue #553: Handle exceptions in inspect.getsourcelines() (hpk42/pytest)

talljosh issues-reply at bitbucket.org
Fri Aug 1 03:35:19 CEST 2014


New issue 553: Handle exceptions in inspect.getsourcelines()
https://bitbucket.org/hpk42/pytest/issue/553/handle-exceptions-in-inspectgetsourcelines

talljosh:

FixtureLookupError uses inspect.getsourcelines() in its formatting, but inspect.getsourcelines() can raise an IOError, which is not handled. This results in the FixtureLookupError being masked by the IOError, which is confusing and unhelpful.

The actual circumstance in which I saw this involved a function decorated with pytest.inlineCallbacks from the pytest-twisted plugin. The decorated function has a filename of "<string>", which stops inspect from being able to find the source code. Although this may be considered to be an issue with the pytest-twisted plugin (or the decorator module which it uses), it would be nice for pytest to actually handle these kinds of exceptions neatly.

I have attached a proposed patch.




More information about the pytest-commit mailing list