Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle exceptions in inspect.getsourcelines() #553

Closed
pytestbot opened this issue Aug 1, 2014 · 4 comments
Closed

Handle exceptions in inspect.getsourcelines() #553

pytestbot opened this issue Aug 1, 2014 · 4 comments
Labels
type: bug problem that needs to be addressed

Comments

@pytestbot
Copy link
Contributor

Originally reported by: BitBucket: talljosh, GitHub: 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 "", 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.


@pytestbot
Copy link
Contributor Author

Original comment by holger krekel (BitBucket: hpk42, GitHub: hpk42):


Do you also have a simple test that exercises the problem?

@pytestbot
Copy link
Contributor Author

Original comment by Bruno Oliveira (BitBucket: nicoddemus, GitHub: nicoddemus):


Handle inspect.getsourcelines failures in FixtureLookupError

Fixes #553

1 similar comment
@pytestbot
Copy link
Contributor Author

Original comment by Bruno Oliveira (BitBucket: nicoddemus, GitHub: nicoddemus):


Handle inspect.getsourcelines failures in FixtureLookupError

Fixes #553

@pytestbot
Copy link
Contributor Author

Original comment by holger krekel (BitBucket: hpk42, GitHub: hpk42):


merged the PR, thanks Bruno.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug problem that needs to be addressed
Projects
None yet
Development

No branches or pull requests

1 participant