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

Adjust monkey_patching to work under pytest #5689

Merged
merged 5 commits into from
Aug 3, 2022
Merged

Conversation

cognifloyd
Copy link
Member

@cognifloyd cognifloyd commented Jul 28, 2022

Background

I'm working towards introducing pants. Eventually I would like to use pants to run tests to take advantage of the fine-grained per-file caching of results that accounts for dependencies by python files (pants infers the deps by reading the python files). But, pants uses pytest to run tests not nosetest.

This is another of several PRs that improves our compatibility with pytest. Others include: #5686, #5690, #5691

Note: I do not have pytest support completely ironed out, but this is a step in that direction. Don't expect running all our tests with pytest to work yet.

Overview

Tests hang (with endless cycles between green threads that can't figure out what to do) when mongoengine gets imported before the monkey patching. So, this adjusts our monkey_patching code and the tests that use mongoengine to make our tests work better under pytest.

We need this because pytest can load test files in any order, or even load only a single test file. Since eventlet monkey_patching is very sensitive to when the monkey_patching happens, we need to make these adjustments or the tests won't work under pytest.

@cognifloyd cognifloyd added this to the 3.8.0 milestone Jul 28, 2022
@cognifloyd cognifloyd added no changelog No Changelog.rst needed for this PR refactor tests labels Jul 28, 2022
@cognifloyd cognifloyd self-assigned this Jul 28, 2022
@pull-request-size pull-request-size bot added the size/L PR that changes 100-499 lines. Requires some effort to review. label Jul 28, 2022
@cognifloyd cognifloyd requested a review from a team July 28, 2022 17:21
@cognifloyd cognifloyd removed the no changelog No Changelog.rst needed for this PR label Jul 28, 2022
Copy link
Contributor

@amanda11 amanda11 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Member

@arm4b arm4b left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@cognifloyd cognifloyd merged commit 7d70498 into master Aug 3, 2022
@cognifloyd cognifloyd deleted the pytest-monkeypatch branch August 3, 2022 21:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pantsbuild refactor size/L PR that changes 100-499 lines. Requires some effort to review. tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants