Skip to content

PYTHON-6287 Fix pytest usage on FIPS hosts - #3247

Open
blink1073 wants to merge 1 commit into
mongodb:mainfrom
blink1073:PYTHON-6287
Open

blink1073 wants to merge 1 commit into
mongodb:mainfrom
blink1073:PYTHON-6287

Conversation

@blink1073

@blink1073 blink1073 commented Nov 23, 2026 •

Copy link
Copy Markdown
Member

PYTHON-6287

Changes in this PR

pytest 9.2 caches rewritten modules as hash-based pycs. The FIPS-hardened RHEL9 interpreter's importlib rejects them, so pytest aborts at plugin load on other-hosts-rhel9-fips-latest. With REQUIRE_FIPS set, setup_tests.py now runs pytest with --assert=plain: no rewrite hook, no hash-based pyc, no abort.

Test Plan

  • just lint: all hooks pass, including the generate-config no-diff check.
  • Patch build on other-hosts-rhel9-fips-latest: three test-no-toolchain tasks must start and run instead of failing at plugin load.

Checklist

Checklist for Author

  • Did you update the changelog (if necessary)? Not necessary: the change only touches evergreen setup scripts.
  • Is there test coverage? Patch build of FIPS
  • Is any followup work tracked in a JIRA ticket? If so, add link(s). N/A

Checklist for Reviewer

  • Does the title of the PR reference a JIRA Ticket?
  • Do you fully understand the implementation? (Would you be comfortable explaining how this code works to someone else?)
  • Is all relevant documentation (README or docstring) updated?

@blink1073 blink1073 changed the title PYTHON-6287 [BF] test-no-toolchain-async-noauth-ssl-replica-set: FIPS mode blocks pytest plugin load on other-hosts rhel9-fips PYTHON-6287 Fix pytest usage on FIPS hosts Nov 23, 2026
@blink1073
blink1073 requested a balanced review from Copilot November 23, 2026 20:06

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

The workaround depends on FIPS-hardened RHEL9 importlib and pytest plugin startup behavior that cannot be reproduced here, and successful results from the three linked test-no-toolchain patch tasks have not been supplied.

No open issues 🎉

What changed in this PR

Updates Evergreen test setup to prevent pytest from aborting during plugin loading on FIPS-hardened hosts due to incompatible hash-based bytecode caches.

Changes:

  • Adds --assert=plain to TEST_ARGS when REQUIRE_FIPS is set, disabling assertion rewriting.
  • Leaves non-FIPS test behavior unchanged.
File Description
.evergreen/​scripts/​setup_tests.py Conditionally disables pytest assertion rewriting for FIPS hosts and documents the workaround.

Review effort: Balanced

@blink1073
blink1073 marked this pull request as ready for review November 23, 2026 20:15
@blink1073
blink1073 requested a review from a team as a code owner November 23, 2026 20:15

This branch has not been deployed

No deployments
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.

3 participants