1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
|
import unittest
try:
from multiprocessing import Process, Queue, Pipe, get_start_method, get_context
disabled = False
except ImportError:
Process = None
Queue = None
Pipe = None
disabled = True
from iniparse import ini
class TestIni(unittest.TestCase):
"""Test sending INIConfig objects."""
# Since Python 3.14 on non-macOS POSIX systems
# the default method has been changed to forkserver.
# The code in this module does not work with it,
# hence the explicit change to 'fork'
# See https://github.com/python/cpython/issues/125714
if get_start_method() == "forkserver":
_mp_context = get_context(method="fork")
else:
_mp_context = get_context()
def test_queue(self):
def getxy(_q, _w):
_cfg = _q.get_nowait()
_w.put(_cfg.x.y)
cfg = ini.INIConfig()
cfg.x.y = '42'
q = Queue()
w = Queue()
q.put(cfg)
p = self._mp_context.Process(target=getxy, args=(q, w))
p.start()
self.assertEqual(w.get(timeout=1), '42')
|