1616import logging
1717import random
1818import typing
19+ from unittest import mock
1920
2021import asynctest
21- import mock
2222import pytest
2323
2424import exec_helpers
@@ -104,6 +104,7 @@ async def read_stream(stream: FakeFileStream):
104104
105105
106106def pytest_generate_tests (metafunc ):
107+ """Tests parametrization."""
107108 if "run_parameters" in metafunc .fixturenames :
108109 metafunc .parametrize (
109110 "run_parameters" ,
@@ -123,6 +124,7 @@ def pytest_generate_tests(metafunc):
123124
124125@pytest .fixture
125126def run_parameters (request ):
127+ """Tests configuration apply."""
126128 return configs [request .param ]
127129
128130
@@ -190,10 +192,12 @@ def create_mock(
190192
191193@pytest .fixture
192194def logger (mocker ):
195+ """Simple mock of logger instance."""
193196 return mocker .patch ("exec_helpers.async_api.subprocess_runner.Subprocess.logger" , autospec = True )
194197
195198
196199async def test_001_execute_async (create_subprocess_shell , logger , run_parameters ) -> None :
200+ """Test low level API."""
197201 runner = exec_helpers .async_api .Subprocess ()
198202 res = await runner .execute_async (
199203 command ,
@@ -246,6 +250,7 @@ async def test_001_execute_async(create_subprocess_shell, logger, run_parameters
246250
247251
248252async def test_002_execute (create_subprocess_shell , logger , exec_result , run_parameters ) -> None :
253+ """Test API without checkers."""
249254 runner = exec_helpers .async_api .Subprocess ()
250255 res = await runner .execute (command , stdin = run_parameters ["stdin" ])
251256 assert isinstance (res , exec_helpers .async_api .ExecResult )
@@ -256,6 +261,7 @@ async def test_002_execute(create_subprocess_shell, logger, exec_result, run_par
256261
257262
258263async def test_003_context_manager (monkeypatch , create_subprocess_shell , logger , exec_result , run_parameters ) -> None :
264+ """Test context manager for threads synchronization."""
259265 lock = asynctest .CoroutineMock ()
260266 lock .attach_mock (asynctest .CoroutineMock ("acquire" ), "acquire" )
261267 lock .attach_mock (mock .Mock ("release" ), "release" )
@@ -272,6 +278,7 @@ async def test_003_context_manager(monkeypatch, create_subprocess_shell, logger,
272278
273279
274280async def test_004_check_call (execute , exec_result , logger ) -> None :
281+ """Test exit code validator."""
275282 runner = exec_helpers .async_api .Subprocess ()
276283 if exec_result .exit_code == exec_helpers .ExitCodes .EX_OK :
277284 assert await runner .check_call (command , stdin = exec_result .stdin ) == exec_result
@@ -294,6 +301,7 @@ async def test_004_check_call(execute, exec_result, logger) -> None:
294301
295302
296303async def test_005_check_call_no_raise (execute , exec_result , logger ) -> None :
304+ """Test exit code validator in permissive mode."""
297305 runner = exec_helpers .async_api .Subprocess ()
298306 res = await runner .check_call (command , stdin = exec_result .stdin , raise_on_err = False )
299307 assert res == exec_result
@@ -306,11 +314,13 @@ async def test_005_check_call_no_raise(execute, exec_result, logger) -> None:
306314
307315
308316async def test_006_check_call_expect (execute , exec_result , logger ) -> None :
317+ """Test exit code validator with custom return codes."""
309318 runner = exec_helpers .async_api .Subprocess ()
310319 assert await runner .check_call (command , stdin = exec_result .stdin , expected = [exec_result .exit_code ]) == exec_result
311320
312321
313322async def test_007_check_stderr (execute , exec_result , logger ) -> None :
323+ """Test STDERR content validator."""
314324 runner = exec_helpers .async_api .Subprocess ()
315325 if not exec_result .stderr :
316326 assert (
@@ -335,6 +345,7 @@ async def test_007_check_stderr(execute, exec_result, logger) -> None:
335345
336346
337347async def test_008_check_stderr_no_raise (execute , exec_result , logger ) -> None :
348+ """Test STDERR content validator in permissive mode."""
338349 runner = exec_helpers .async_api .Subprocess ()
339350 assert (
340351 await runner .check_stderr (
@@ -345,6 +356,7 @@ async def test_008_check_stderr_no_raise(execute, exec_result, logger) -> None:
345356
346357
347358async def test_009_call (create_subprocess_shell , logger , exec_result , run_parameters ) -> None :
359+ """Test callable."""
348360 runner = exec_helpers .async_api .Subprocess ()
349361 res = await runner (command , stdin = run_parameters ["stdin" ])
350362 assert isinstance (res , exec_helpers .async_api .ExecResult )
0 commit comments