Skip to content

Don't ignore ImportError when importing setuptools plugins #1564

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

Merged
merged 1 commit into from
Jun 25, 2016
Merged

Don't ignore ImportError when importing setuptools plugins #1564

merged 1 commit into from
Jun 25, 2016

Conversation

The-Compiler
Copy link
Member

@The-Compiler The-Compiler commented May 23, 2016

This was added in b2d66b9 but is a bad idea. When a plugin can't be imported, commandline options (optionally set in pytest.ini) could be undefined, which means pytest bails out much earlier before showing the warning, which is hard to debug.

Fixes #1479, also see #1307 and #1497

@The-Compiler The-Compiler changed the title WIP: Don't ignore ImportError when importing setuptools plugins Don't ignore ImportError when importing setuptools plugins May 23, 2016
@The-Compiler
Copy link
Member Author

The-Compiler commented May 23, 2016

Looks good now - @hpk42 got a minute to review this, as this is basically a revert of your change in b2d66b9?

@wichert
Copy link

wichert commented May 23, 2016

It might be nice to add a more user friendly message to the user. If you let Python print the stack trace like I think you are doing now, will it be clear to a user which entry point failed to load? Adding a try/catch/warn/re-raise bit to the plugin manager is probably needed to do that.

@The-Compiler
Copy link
Member Author

I think the filenames in the stacktrace should make it clear what plugin failed - and either way, that'd be a separate PR to pluggy.

@RonnyPfannschmidt
Copy link
Member

why do we actually notsee those warnings?

i'd rather like to propose we always show

@The-Compiler
Copy link
Member Author

As mentioned in the message, because pytest bails out earlier when e.g. a commandline option is used but not defined because the import failed.

I'd like to ask a different question: Why is failing to import a plugin (which could invoke any unwanted/undefined behaviour) a warning and not an error?

@RonnyPfannschmidt
Copy link
Member

hmm, i'm not sure, but i'd happily do a major release to change that bit i think

@nicoddemus
Copy link
Member

Why is failing to import a plugin (which could invoke any unwanted/undefined behaviour) a warning and not an error?

I also wondered this myself. FWIW I would also like for this to be a hard error.

@The-Compiler
Copy link
Member Author

Similar to the added error when no tests were collected, I don't think stopping to hide an error and replacing it with a very confusing different error ("unrecognized arguments") should wait until a major release.

At least 5 people did a lot of digging because of this behaviour now... let's stop hiding errors already. If a test environment has a plugin installed which raises an ImportError, it's broken and deserves to fail 😉

@nicoddemus
Copy link
Member

Similar to the added error when no tests were collected, I don't think stopping to hide an error and replacing it with a very confusing different error ("unrecognized arguments") should wait until a major release.

👍

@RonnyPfannschmidt
Copy link
Member

this is a incompatible external behavior change, so in my book this warrants a immediate major release to cope ^^

@nicoddemus
Copy link
Member

this is a incompatible external behavior change

IMHO I consider this a bug. While I understand some CI setup with a broken plugin might start failing when upgrading pytest, I don't think there's anybody counting on this behavior. The current behavior is really undesirable IMO, myself having spent sometime trying to figure out why some fixture was missing from a run (qtbot), only to find out the problem was an ImportError on a different plugin.

If you feel strongly about this, a compromise would be change the target of this PR to features and let out this change in 2.10 only.

@RonnyPfannschmidt
Copy link
Member

hmm, i think my point is not getting across, i'm fine with immediately releasing master as 3.0 as soon a fix for this one merged the version change is simply to be in with line with semver

i'm also fine with any other way to get this fix out asap, i'm just unhappy that we'd not follow semver to the best of our knowledge

@RonnyPfannschmidt
Copy link
Member

as for the rationale, i am reasonably certain this one will break some random cooperate testsuites simply due to neglect that will happen, breaking changes get major numbers

@nicoddemus
Copy link
Member

i'm just unhappy that we'd not follow semver to the best of our knowledge

Hmm I see.

as for the rationale, i am reasonably certain this one will break some random cooperate testsuites simply due to neglect that will happen, breaking changes get major numbers

That might happen, true.

Well, we will have a chance to discuss this in person in a few weeks. 😁

@The-Compiler
Copy link
Member Author

I see where you're coming from, but if we increment the major version for every version which introduces a behavior change in some obscure way, we'll end up with Firefox pytest 46 soon 😉

That being said, I'm okay with delaying this until the sprint and releasing a 3.0 during or shortly after the sprint.

@RonnyPfannschmidt
Copy link
Member

i don't see a problem with high version numbers - and its preferable to go for small handle-able changes per major iterations over completely breaking the world

@blueyed
Copy link
Contributor

blueyed commented Jun 22, 2016

This seems to be something to target for pytest 3.0, right?

@RonnyPfannschmidt
Copy link
Member

Yes

@nicoddemus
Copy link
Member

Agreed, could you rebase it @The-Compiler?

This was added in b2d66b9 but is a bad
idea. When a plugin can't be imported, commandline options (optionally
set in pytest.ini) could be undefined, which means pytest bails out
much earlier before showing the warning, which is hard to debug.

Fixes #1479, also see #1307 and #1497
@The-Compiler
Copy link
Member Author

What's the rebase needed for? Just so the tests rerun with the latest code?

Anyways, rebased on latest master.

@The-Compiler The-Compiler added this to the 3.0 milestone Jun 25, 2016
@The-Compiler The-Compiler removed their assignment Jun 25, 2016
@coveralls
Copy link

coveralls commented Jun 25, 2016

Coverage Status

Coverage increased (+0.03%) to 92.265% when pulling 757f37f on The-Compiler:issue1479 into 0c63762 on pytest-dev:master.

@RonnyPfannschmidt RonnyPfannschmidt merged commit 70ea3ce into pytest-dev:master Jun 25, 2016
The-Compiler added a commit that referenced this pull request Jun 25, 2016
nicoddemus added a commit that referenced this pull request Jun 25, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants