File: process_test.py

package info (click to toggle)
aioprocessing 2.0.1-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 228 kB
  • sloc: python: 1,463; sh: 13; makefile: 9
file content (38 lines) | stat: -rw-r--r-- 767 bytes parent folder | download
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
import aioprocessing.mp as multiprocessing

import aioprocessing
from ._base_test import BaseTest, _GenMixin


def f(q, a, b):
    q.put((a, b))


def dummy():
    pass


class GenAioProcessTest(BaseTest, _GenMixin):
    def setUp(self):
        self.Obj = aioprocessing.AioProcess
        self.inst = self.Obj(target=dummy)
        self.meth = "coro_join"


class ProcessTest(BaseTest):
    def test_pickle_queue(self):
        t = ("a", "b")
        q = multiprocessing.Queue()
        p = aioprocessing.AioProcess(target=f, args=(q,) + t)
        p.start()

        async def join():
            await p.coro_join()

        self.loop.run_until_complete(join())
        self.assertEqual(q.get(), t)


if __name__ == "__main__":
    unittest.main()