From fa0f362c7f0e8ac93b4cea02d5a1581b94d3f7a1 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 18 Jan 2024 15:44:45 +0000 Subject: [PATCH] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- tests/test_context.py | 44 +++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/tests/test_context.py b/tests/test_context.py index b0ac32b8..b8d4d2f1 100644 --- a/tests/test_context.py +++ b/tests/test_context.py @@ -176,7 +176,7 @@ def test_contextmanager_exception(self, context, event_loop): assert exc.value is exception @pytest.mark.anyio - @pytest.mark.parametrize('anyio_backend', ['asyncio']) + @pytest.mark.parametrize("anyio_backend", ["asyncio"]) async def test_async_contextmanager_exception(self, event_loop, context): """Test that "async with context:" calls close() with the exception raised in the block.""" close_future = event_loop.create_future() @@ -416,7 +416,7 @@ def factory(ctx: Context) -> Optional[str]: # noqa: UP007 assert context.require_resource(str) == "foo" @pytest.mark.anyio - @pytest.mark.parametrize('anyio_backend', ['asyncio']) + @pytest.mark.parametrize("anyio_backend", ["asyncio"]) async def test_getattr_attribute_error(self, context: Context) -> None: async with context, Context() as child_context: pytest.raises(AttributeError, getattr, child_context, "foo").match( @@ -424,7 +424,7 @@ async def test_getattr_attribute_error(self, context: Context) -> None: ) @pytest.mark.anyio - @pytest.mark.parametrize('anyio_backend', ['asyncio']) + @pytest.mark.parametrize("anyio_backend", ["asyncio"]) async def test_getattr_parent(self, context: Context) -> None: """ Test that accessing a nonexistent attribute on a context retrieves the value from parent. @@ -435,7 +435,7 @@ async def test_getattr_parent(self, context: Context) -> None: assert child_context.a == 2 @pytest.mark.anyio - @pytest.mark.parametrize('anyio_backend', ['asyncio']) + @pytest.mark.parametrize("anyio_backend", ["asyncio"]) async def test_get_resources(self, context: Context) -> None: context.add_resource(9, "foo") context.add_resource_factory(lambda ctx: len(ctx.context_chain), int, "bar") @@ -445,7 +445,7 @@ async def test_get_resources(self, context: Context) -> None: assert subctx.get_resources(int) == {1, 4} @pytest.mark.anyio - @pytest.mark.parametrize('anyio_backend', ['asyncio']) + @pytest.mark.parametrize("anyio_backend", ["asyncio"]) async def test_require_resource(self, context: Context) -> None: context.add_resource(1) assert context.require_resource(int) == 1 @@ -476,7 +476,7 @@ async def add_resource(): assert resource == 6 @pytest.mark.anyio - @pytest.mark.parametrize('anyio_backend', ['asyncio']) + @pytest.mark.parametrize("anyio_backend", ["asyncio"]) async def test_request_resource_factory_context_attr(self, context: Context) -> None: """Test that requesting a factory-generated resource also sets the context variable.""" with pytest.deprecated_call(): @@ -486,7 +486,7 @@ async def test_request_resource_factory_context_attr(self, context: Context) -> assert context.__dict__["foo"] == 6 @pytest.mark.anyio - @pytest.mark.parametrize('anyio_backend', ['asyncio']) + @pytest.mark.parametrize("anyio_backend", ["asyncio"]) async def test_call_async_plain(self, context: Context) -> None: def runs_in_event_loop(worker_thread: Thread, x: int, y: int) -> int: assert current_thread() is not worker_thread @@ -499,7 +499,7 @@ def runs_in_worker_thread() -> int: assert await context.call_in_executor(runs_in_worker_thread) == 3 @pytest.mark.anyio - @pytest.mark.parametrize('anyio_backend', ['asyncio']) + @pytest.mark.parametrize("anyio_backend", ["asyncio"]) async def test_call_async_coroutine(self, context: Context) -> None: async def runs_in_event_loop(worker_thread, x, y): assert current_thread() is not worker_thread @@ -513,7 +513,7 @@ def runs_in_worker_thread() -> int: assert await context.call_in_executor(runs_in_worker_thread) == 3 @pytest.mark.anyio - @pytest.mark.parametrize('anyio_backend', ['asyncio']) + @pytest.mark.parametrize("anyio_backend", ["asyncio"]) async def test_call_async_exception(self, context: Context) -> None: def runs_in_event_loop() -> NoReturn: raise ValueError("foo") @@ -524,7 +524,7 @@ def runs_in_event_loop() -> NoReturn: assert exc.match("foo") @pytest.mark.anyio - @pytest.mark.parametrize('anyio_backend', ['asyncio']) + @pytest.mark.parametrize("anyio_backend", ["asyncio"]) async def test_call_in_executor(self, context: Context) -> None: """Test that call_in_executor actually runs the target in a worker thread.""" worker_thread = await context.call_in_executor(current_thread) @@ -532,7 +532,7 @@ async def test_call_in_executor(self, context: Context) -> None: @pytest.mark.parametrize("use_resource_name", [True, False], ids=["direct", "resource"]) @pytest.mark.anyio - @pytest.mark.parametrize('anyio_backend', ['asyncio']) + @pytest.mark.parametrize("anyio_backend", ["asyncio"]) async def test_call_in_executor_explicit(self, context, use_resource_name): executor = ThreadPoolExecutor(1) context.add_resource(executor, types=[Executor]) @@ -542,7 +542,7 @@ async def test_call_in_executor_explicit(self, context, use_resource_name): assert worker_thread is not current_thread() @pytest.mark.anyio - @pytest.mark.parametrize('anyio_backend', ['asyncio']) + @pytest.mark.parametrize("anyio_backend", ["asyncio"]) async def test_call_in_executor_context_preserved(self, context: Context) -> None: """ Test that call_in_executor runs the callable in a copy of the current (PEP 567) @@ -553,14 +553,14 @@ async def test_call_in_executor_context_preserved(self, context: Context) -> Non assert await context.call_in_executor(current_context) is ctx @pytest.mark.anyio - @pytest.mark.parametrize('anyio_backend', ['asyncio']) + @pytest.mark.parametrize("anyio_backend", ["asyncio"]) async def test_threadpool(self, context: Context) -> None: event_loop_thread = current_thread() async with context.threadpool(): assert current_thread() is not event_loop_thread @pytest.mark.anyio - @pytest.mark.parametrize('anyio_backend', ['asyncio']) + @pytest.mark.parametrize("anyio_backend", ["asyncio"]) async def test_threadpool_named_executor( self, context: Context, special_executor: Executor ) -> None: @@ -571,7 +571,7 @@ async def test_threadpool_named_executor( class TestExecutor: @pytest.mark.anyio - @pytest.mark.parametrize('anyio_backend', ['asyncio']) + @pytest.mark.parametrize("anyio_backend", ["asyncio"]) async def test_no_arguments(self, context: Context) -> None: @executor def runs_in_default_worker() -> None: @@ -583,7 +583,7 @@ def runs_in_default_worker() -> None: await runs_in_default_worker() @pytest.mark.anyio - @pytest.mark.parametrize('anyio_backend', ['asyncio']) + @pytest.mark.parametrize("anyio_backend", ["asyncio"]) async def test_named_executor(self, context: Context, special_executor: Executor) -> None: @executor("special") def runs_in_default_worker(ctx: Context) -> None: @@ -595,7 +595,7 @@ def runs_in_default_worker(ctx: Context) -> None: await runs_in_default_worker(context) @pytest.mark.anyio - @pytest.mark.parametrize('anyio_backend', ['asyncio']) + @pytest.mark.parametrize("anyio_backend", ["asyncio"]) async def test_executor_missing_context(self, context: Context): @executor("special") def runs_in_default_worker() -> None: @@ -725,7 +725,7 @@ async def start(ctx: Context) -> None: ], ) @pytest.mark.anyio - @pytest.mark.parametrize('anyio_backend', ['asyncio']) + @pytest.mark.parametrize("anyio_backend", ["asyncio"]) async def test_get_resource_at_teardown(self, resource_func) -> None: resource = "" @@ -750,7 +750,7 @@ async def teardown_callback() -> None: ], ) @pytest.mark.anyio - @pytest.mark.parametrize('anyio_backend', ['asyncio']) + @pytest.mark.parametrize("anyio_backend", ["asyncio"]) async def test_generate_resource_at_teardown(self, resource_func) -> None: resource = "" @@ -793,7 +793,7 @@ async def start(ctx: Context) -> AsyncIterator[None]: @pytest.mark.anyio -@pytest.mark.parametrize('anyio_backend', ['asyncio']) +@pytest.mark.parametrize("anyio_backend", ["asyncio"]) async def test_current_context() -> None: pytest.raises(NoCurrentContext, current_context) @@ -808,7 +808,7 @@ async def test_current_context() -> None: @pytest.mark.anyio -@pytest.mark.parametrize('anyio_backend', ['asyncio']) +@pytest.mark.parametrize("anyio_backend", ["asyncio"]) async def test_get_resource() -> None: async with Context() as ctx: ctx.add_resource("foo") @@ -817,7 +817,7 @@ async def test_get_resource() -> None: @pytest.mark.anyio -@pytest.mark.parametrize('anyio_backend', ['asyncio']) +@pytest.mark.parametrize("anyio_backend", ["asyncio"]) async def test_require_resource() -> None: async with Context() as ctx: ctx.add_resource("foo")