-
-
Notifications
You must be signed in to change notification settings - Fork 632
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
Fix PytestRun to honor user conftest.py
plugins.
#7784
Fix PytestRun to honor user conftest.py
plugins.
#7784
Conversation
Previously codebases that leveraged pytest's `conftest.py` support could fail when tested with pants test in various situations. This was ultimately because we injected out own `conftest.py` to register our custom pytest plugins and plugin discovery of `conftest.py` plugins is brittle. We avoid the brittleness by moving our plugin into a `sys.path` module activated with `-p` fixing a previously failing test added in `test_conftests_discovery_with_coverage`.
import pytest | ||
|
||
|
||
class NodeRenamerPlugin(object): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NB: This is mainly a move from _get_conftest_content
on the LHS.
item._nodeid = real_nodeid | ||
|
||
|
||
class ShardingPlugin(object): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NB: This is mainly a move from _get_shard_conftest_content
on the LHS.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't have enough context on this repo to give a useful review. but looks fine to me.
I'm going to submit but I'll circle back if there is any further feedback. |
Previously codebases that leveraged pytest's
conftest.py
support couldfail when tested with
./pants test
in various situations. This wasultimately because we injected our own
conftest.py
to register ourcustom pytest plugins and plugin discovery of
conftest.py
plugins isbrittle. We avoid the brittleness by moving our plugin into a
sys.path
module activated with
-p
fixing a previously failing test added intest_conftests_discovery_with_coverage
.