omlish 0.0.0.dev195__py3-none-any.whl → 0.0.0.dev197__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. omlish/__about__.py +3 -3
  2. omlish/asyncs/asyncio/all.py +0 -1
  3. omlish/asyncs/asyncio/asyncio.py +2 -6
  4. omlish/asyncs/bluelet/runner.py +1 -1
  5. omlish/asyncs/bridge.py +2 -2
  6. omlish/codecs/base.py +5 -5
  7. omlish/codecs/text.py +1 -2
  8. omlish/io/compress/adapters.py +4 -4
  9. omlish/io/compress/base.py +4 -4
  10. omlish/io/compress/bz2.py +4 -4
  11. omlish/io/compress/codecs.py +2 -2
  12. omlish/io/compress/gzip.py +10 -10
  13. omlish/io/compress/lz4.py +5 -5
  14. omlish/io/compress/lzma.py +4 -4
  15. omlish/io/compress/zlib.py +4 -4
  16. omlish/io/coro/__init__.py +56 -0
  17. omlish/io/coro/direct.py +13 -0
  18. omlish/io/{generators → coro}/readers.py +31 -31
  19. omlish/io/{generators → coro}/stepped.py +28 -28
  20. omlish/multiprocessing/__init__.py +32 -0
  21. omlish/{multiprocessing.py → multiprocessing/death.py} +3 -88
  22. omlish/multiprocessing/proxies.py +30 -0
  23. omlish/multiprocessing/spawn.py +59 -0
  24. omlish/os/atomics.py +2 -2
  25. omlish/outcome.py +250 -0
  26. omlish/sockets/server.py +1 -2
  27. omlish/term/vt100/terminal.py +1 -1
  28. omlish/testing/pytest/__init__.py +0 -4
  29. omlish/testing/pytest/plugins/asyncs/__init__.py +1 -0
  30. omlish/testing/pytest/plugins/asyncs/backends/__init__.py +16 -0
  31. omlish/testing/pytest/plugins/asyncs/backends/asyncio.py +35 -0
  32. omlish/testing/pytest/plugins/asyncs/backends/base.py +30 -0
  33. omlish/testing/pytest/plugins/asyncs/backends/trio.py +91 -0
  34. omlish/testing/pytest/plugins/asyncs/backends/trio_asyncio.py +89 -0
  35. omlish/testing/pytest/plugins/asyncs/consts.py +3 -0
  36. omlish/testing/pytest/plugins/asyncs/fixtures.py +273 -0
  37. omlish/testing/pytest/plugins/asyncs/plugin.py +182 -0
  38. omlish/testing/pytest/plugins/asyncs/utils.py +10 -0
  39. omlish/testing/pytest/plugins/managermarks.py +0 -14
  40. omlish/text/indent.py +1 -1
  41. omlish/text/minja.py +2 -2
  42. {omlish-0.0.0.dev195.dist-info → omlish-0.0.0.dev197.dist-info}/METADATA +5 -5
  43. {omlish-0.0.0.dev195.dist-info → omlish-0.0.0.dev197.dist-info}/RECORD +48 -36
  44. {omlish-0.0.0.dev195.dist-info → omlish-0.0.0.dev197.dist-info}/WHEEL +1 -1
  45. omlish/io/generators/__init__.py +0 -56
  46. omlish/io/generators/direct.py +0 -13
  47. omlish/testing/pytest/marks.py +0 -18
  48. omlish/testing/pytest/plugins/asyncs.py +0 -162
  49. /omlish/io/{generators → coro}/consts.py +0 -0
  50. {omlish-0.0.0.dev195.dist-info → omlish-0.0.0.dev197.dist-info}/LICENSE +0 -0
  51. {omlish-0.0.0.dev195.dist-info → omlish-0.0.0.dev197.dist-info}/entry_points.txt +0 -0
  52. {omlish-0.0.0.dev195.dist-info → omlish-0.0.0.dev197.dist-info}/top_level.txt +0 -0
@@ -1,162 +0,0 @@
1
- """
2
- TODO:
3
- - auto drain_asyncio
4
-
5
- ==
6
-
7
- _pytest:
8
- https://github.com/pytest-dev/pytest/blob/ef9b8f9d748b6f50eab5d43e32d93008f7880899/src/_pytest/python.py#L155
9
- "async def function and no async plugin installed (see warnings)"
10
-
11
- pytest_trio:
12
- https://github.com/python-trio/pytest-trio/blob/f03160aa1dd355a12d39fa21f4aee4e1239efea3/pytest_trio/plugin.py
13
- - pytest_addoption
14
- - pytest_configure
15
- - pytest_collection_modifyitems
16
- - pytest_runtest_call @(hookwrapper=True)
17
- - pytest_fixture_setup
18
-
19
- pytest_asyncio:
20
- https://github.com/pytest-dev/pytest-asyncio/blob/f45aa18cf3eeeb94075de16a1d797858facab863/pytest_asyncio/plugin.py
21
- - pytest_addoption
22
- - pytest_configure
23
- - pytest_pycollect_makeitem_preprocess_async_fixtures @(specname="pytest_pycollect_makeitem", tryfirst=True)
24
- - pytest_pycollect_makeitem_convert_async_functions_to_subclass @(specname="pytest_pycollect_makeitem", hookwrapper=True)
25
- - pytest_generate_tests @(tryfirst=True)
26
- - pytest_runtest_setup(item: pytest.Item) -> None:
27
- - pytest_pyfunc_call @(tryfirst=True, hookwrapper=True)
28
- - pytest_collectstart @()
29
- - pytest_report_header @(tryfirst=True)
30
- - pytest_fixture_setup @(hookwrapper=True)
31
-
32
- anyio.pytest_plugin:
33
- https://github.com/agronholm/anyio/blob/8907964926a24461840eee0925d3f355e729f15d/src/anyio/pytest_plugin.py
34
- - pytest_configure
35
- - pytest_pycollect_makeitem @(tryfirst=True)
36
- - pytest_pyfunc_call @(tryfirst=True)
37
- - pytest_fixture_setup
38
-
39
- """ # noqa
40
- import functools
41
- import inspect
42
- import sys
43
- import typing as ta
44
- import warnings
45
-
46
- import pytest
47
-
48
- from .... import lang
49
- from ....asyncs import trio_asyncio as trai
50
- from ....diag import pydevd as pdu
51
- from ._registry import register
52
-
53
-
54
- if ta.TYPE_CHECKING:
55
- import trio_asyncio
56
- else:
57
- trio_asyncio = lang.proxy_import('trio_asyncio')
58
-
59
-
60
- ASYNCS_MARK = 'asyncs'
61
-
62
- KNOWN_BACKENDS = (
63
- 'asyncio',
64
- 'trio',
65
- 'trio_asyncio',
66
- )
67
-
68
- PARAM_NAME = '__async_backend'
69
-
70
-
71
- def iscoroutinefunction(func: ta.Any) -> bool:
72
- return inspect.iscoroutinefunction(func) or getattr(func, '_is_coroutine', False)
73
-
74
-
75
- def is_async_function(func: ta.Any) -> bool:
76
- return iscoroutinefunction(func) or inspect.isasyncgenfunction(func)
77
-
78
-
79
- @register
80
- class AsyncsPlugin:
81
- ASYNC_BACKENDS: ta.ClassVar[ta.Sequence[str]] = [
82
- *[s for s in KNOWN_BACKENDS if lang.can_import(s)],
83
- ]
84
-
85
- def pytest_cmdline_main(self, config):
86
- if (aio_plugin := sys.modules.get('pytest_asyncio.plugin')):
87
- # warnings.filterwarnings is clobbered by pytest using warnings.catch_warnings
88
- def aio_plugin_warn(message, *args, **kwargs):
89
- if (
90
- isinstance(message, pytest.PytestDeprecationWarning) and
91
- message.args[0].startswith('The configuration option "asyncio_default_fixture_loop_scope" is unset.') # noqa
92
- ):
93
- return
94
- warnings.warn(message, *args, **kwargs)
95
-
96
- aio_plugin.warnings = lang.proxy_import('warnings') # type: ignore
97
- aio_plugin.warnings.warn = aio_plugin_warn # type: ignore
98
-
99
- def pytest_configure(self, config):
100
- config.addinivalue_line('markers', f'{ASYNCS_MARK}: marks for all async backends')
101
- config.addinivalue_line('markers', 'trio_asyncio: marks for trio_asyncio backend')
102
-
103
- def pytest_generate_tests(self, metafunc):
104
- if (m := metafunc.definition.get_closest_marker(ASYNCS_MARK)) is not None:
105
- if m.args:
106
- bes = m.args
107
- else:
108
- bes = self.ASYNC_BACKENDS
109
- elif metafunc.definition.get_closest_marker('trio_asyncio') is not None:
110
- bes = ['trio_asyncio']
111
- else:
112
- return
113
-
114
- if 'trio_asyncio' in bes:
115
- # NOTE: Importing it here is apparently necessary to get its patching working - otherwise fails later with
116
- # `no running event loop` in anyio._backends._asyncio and such.
117
- import trio_asyncio # noqa
118
-
119
- if pdu.is_present():
120
- pdu.patch_for_trio_asyncio()
121
-
122
- metafunc.fixturenames.append(PARAM_NAME)
123
- metafunc.parametrize(PARAM_NAME, bes)
124
-
125
- for c in metafunc._calls: # noqa
126
- be = c.params[PARAM_NAME]
127
- if be == 'trio_asyncio':
128
- c.marks.extend([
129
- pytest.mark.trio.mark,
130
- pytest.mark.trio_asyncio.mark,
131
- ])
132
-
133
- else:
134
- c.marks.append(getattr(pytest.mark, be).mark)
135
-
136
- if pdu.is_present():
137
- c.marks.append(pytest.mark.drain_asyncio.mark)
138
-
139
- @pytest.hookimpl(hookwrapper=True)
140
- def pytest_runtest_call(self, item):
141
- bes = [be for be in self.ASYNC_BACKENDS if item.get_closest_marker(be) is not None]
142
- if len(bes) > 1 and set(bes) != {'trio', 'trio_asyncio'}:
143
- raise Exception(f'{item.nodeid}: multiple async backends specified: {bes}')
144
- elif is_async_function(item.obj) and not bes:
145
- from _pytest.unittest import UnitTestCase # noqa
146
- if isinstance(item.parent, UnitTestCase):
147
- # unittest handles these itself.
148
- pass
149
- else:
150
- raise Exception(f'{item.nodeid}: async def function and no async plugin specified')
151
-
152
- if 'trio_asyncio' in bes:
153
- obj = item.obj
154
-
155
- @functools.wraps(obj)
156
- @trai.with_trio_asyncio_loop(wait=True)
157
- async def run(*args, **kwargs):
158
- await trio_asyncio.aio_as_trio(obj)(*args, **kwargs)
159
-
160
- item.obj = run
161
-
162
- yield
File without changes