From fed6e9872094908fae4fe6a441430fdb2d6b9b77 Mon Sep 17 00:00:00 2001
From: Karolina Surma <ksurma@redhat.com>
Date: Fri, 30 May 2025 13:46:29 +0200
Subject: [PATCH] Avoid the multiprocessing forkserver method

---
 tests/unit/test_compat.py | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/tests/unit/test_compat.py b/tests/unit/test_compat.py
index 20f07c74..a50ad10a 100644
--- a/tests/unit/test_compat.py
+++ b/tests/unit/test_compat.py
@@ -10,6 +10,7 @@
 # distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
 # ANY KIND, either express or implied. See the License for the specific
 # language governing permissions and limitations under the License.
+import multiprocessing
 import os
 import shutil
 import signal
@@ -80,7 +81,15 @@ def test_non_file_like_obj(self):
 class TestBaseManager(unittest.TestCase):
     def create_pid_manager(self):
         class PIDManager(BaseManager):
-            pass
+            def __init__(self):
+                # Python 3.14 changed the non-macOS POSIX default to forkserver
+                # but the code in this module does not work with it
+                # See https://github.com/python/cpython/issues/125714
+                if multiprocessing.get_start_method() == 'forkserver':
+                    ctx = multiprocessing.get_context(method='fork')
+                else:
+                    ctx = multiprocessing.get_context()
+                super().__init__(ctx=ctx)
 
         PIDManager.register('getpid', os.getpid)
         return PIDManager()
