mirror of
https://gerrit.googlesource.com/git-repo
synced 2026-11-14 08:17:16 +00:00
Python 3.14 changed the default multiprocessing start method on Linux from "fork" to "forkserver". The test_forall_all_projects_called_once test uses mock.patch.object on Project.GetRevisionId, but class-level mock patches do not survive into forkserver worker processes because they start from a clean Python interpreter rather than inheriting the parent's memory. Replace the mock with setting revisionId directly on each Project instance so GetRevisionId() short-circuits without touching git. This works with any multiprocessing start method since the string attribute is part of the Project objects stored in _parallel_context, which is properly serialized to workers via initargs. Bug: 425319437 Change-Id: Icd3bbd010921d7652bb2425fad85974df9198367 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/602941 Tested-by: Brian Gan <brgan@google.com> Commit-Queue: Brian Gan <brgan@google.com> Reviewed-by: Gavin Mak <gavinmak@google.com>
Repo Tests
There is a mixture of pytest & Python unittest in here. We adopted pytest later on but didn't migrate existing tests (since they still work). New tests should be written using pytest only.
File layout
test_xxx.py: Unittests for thexxxmodule in the main repo codebase. Modules that are in subdirs normalize the/into_. For example, test_error.py is for the error.py module, and test_subcmds_forall.py is for the subcmds/forall.py module.- conftest.py: Custom pytest fixtures for sharing.
- utils_for_test.py: Helpers for sharing in tests.