Skip to content

Conversation

gaborbernat
Copy link
Member

@gaborbernat gaborbernat commented Aug 20, 2025

The old sys_platform fixture patched sys.platform globally:

monkeypatch.setattr(sys, "platform", request.param)

With the latest virtualenv release, tox’s test suite sometimes imports virtualenv.discovery.info while this global patch is active. ⚠️ That causes other tests to see the wrong sys.platform, breaking CI.

🛠️ Solution

  • Introduced a _SelectiveSys proxy (ModuleType subclass) that overrides only platform while delegating everything else to the real sys.
  • Updated the fixture to patch sys only inside tox.config.loader.str_convert, leaving all other modules (including virtualenv) untouched.

✅ Benefits

  • CI stability restored ✅
  • Test isolation improved (no more leaking patched sys.platform into unrelated imports).
  • Future-proof against similar upstream changes in virtualenv or other tools.

Resolves pypa/virtualenv#2959

@gaborbernat gaborbernat marked this pull request as draft August 20, 2025 13:47
@gaborbernat gaborbernat force-pushed the fix-ci branch 3 times, most recently from d1465ff to a346cf5 Compare August 20, 2025 17:20
@gaborbernat gaborbernat changed the title Fix the CI 🐍 Fix sys_platform Fixture Leakage breaking the CI Aug 20, 2025
@gaborbernat gaborbernat marked this pull request as ready for review August 20, 2025 17:30
@gaborbernat gaborbernat enabled auto-merge (squash) August 20, 2025 17:31
@gaborbernat gaborbernat merged commit 18d2943 into tox-dev:main Aug 20, 2025
54 of 55 checks passed
@gaborbernat gaborbernat deleted the fix-ci branch August 20, 2025 18:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

New virtualenv breaks tox CI

1 participant