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

Fix PytestRun to honor user `conftest.py` plugins. #7784

Merged
merged 2 commits into from May 21, 2019

Conversation

Projects
None yet
2 participants
@jsirois
Copy link
Member

commented May 21, 2019

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 our 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.

Fix PytestRun to honor user `conftest.py` plugins.
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):

This comment has been minimized.

Copy link
@jsirois

jsirois May 21, 2019

Author Member

NB: This is mainly a move from _get_conftest_content on the LHS.

item._nodeid = real_nodeid


class ShardingPlugin(object):

This comment has been minimized.

Copy link
@jsirois

jsirois May 21, 2019

Author Member

NB: This is mainly a move from _get_shard_conftest_content on the LHS.

@jsirois jsirois requested review from asherf and Eric-Arellano May 21, 2019

@asherf

asherf approved these changes May 21, 2019

Copy link

left a comment

I don't have enough context on this repo to give a useful review. but looks fine to me.

@jsirois

This comment has been minimized.

Copy link
Member Author

commented May 21, 2019

I'm going to submit but I'll circle back if there is any further feedback.

@jsirois jsirois merged commit b3cdd8a into pantsbuild:master May 21, 2019

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details

@jsirois jsirois deleted the jsirois:pytest/dont-pollute-conftest branch May 21, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.