File: test_dependencies.py

package info (click to toggle)
apt-mirror2 15-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,388 kB
  • sloc: python: 5,337; sh: 23; makefile: 14
file content (40 lines) | stat: -rw-r--r-- 1,100 bytes parent folder | download | duplicates (2)
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
39
40
import platform
from unittest import IsolatedAsyncioTestCase

from caio import linux_aio_asyncio, thread_aio_asyncio


class TestAIOFile(IsolatedAsyncioTestCase):
    def __init__(self, methodName: str = "runTest") -> None:
        super().__init__(methodName)
        self._platform = platform.system().lower()

    def linux_aio_supported(self):
        if "linux" not in self._platform:
            return False

        if platform.python_implementation() != "CPython":
            return False

        return True

    def thread_aio_supported(self):
        if "linux" not in self._platform and "darwin" not in self._platform:
            return False

        if platform.python_implementation() != "CPython":
            return False

    async def test_linux_aio(self):
        if not self.linux_aio_supported():
            return

        async with linux_aio_asyncio.AsyncioContext() as _:
            pass

    async def test_thread_aio(self):
        if not self.thread_aio_supported():
            return

        async with thread_aio_asyncio.AsyncioContext() as _:
            pass