From b130bcafaaa7612de39ee0c15511bd119101c70b Mon Sep 17 00:00:00 2001 From: Emily Date: Thu, 11 Sep 2025 14:57:44 +0100 Subject: [PATCH] Use `unix_sockname` fixture for `test_run_app_preexisting_unix_socket` (#11498) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## What do these changes do? Fixes the tests in sandboxed build environments where `/tmp` is not accessible. ## Are there changes in behavior for the user? No. ## Is it a substantial burden for the maintainers to support this? Hopefully not: the fixture is used elsewhere in the tests for the same purpose. ## Related issue number ## Checklist - [x] I think the code is well written - [x] Unit tests for the changes exist *(well, the change is to a unit test…)* - [x] Documentation reflects the changes - [ ] If you provide code modification, please add yourself to `CONTRIBUTORS.txt` *(patch is too trivial to even be copyrightable, I feel no need for credit beyond the commit log)* * The format is <Name> <Surname>. * Please keep alphabetical order, the file is sorted by names. - [ ] Add a new news fragment into the `CHANGES/` folder *(too trivial to changelog)* * name it `..rst` (e.g. `588.bugfix.rst`) * if you don't have an issue number, change it to the pull request number after creating the PR * `.bugfix`: A bug fix for something the maintainers deemed an improper undesired behavior that got corrected to match pre-agreed expectations. * `.feature`: A new behavior, public APIs. That sort of stuff. * `.deprecation`: A declaration of future API removals and breaking changes in behavior. * `.breaking`: When something public is removed in a breaking way. Could be deprecated in an earlier release. * `.doc`: Notable updates to the documentation structure or build process. * `.packaging`: Notes for downstreams about unobvious side effects and tooling. Changes in the test invocation considerations and runtime assumptions. * `.contrib`: Stuff that affects the contributor experience. e.g. Running tests, building the docs, setting up the development environment. * `.misc`: Changes that are hard to assign to any of the above categories. * Make sure to use full sentences with correct case and punctuation, for example: ```rst Fixed issue with non-ascii contents in doctest text files -- by :user:`contributor-gh-handle`. ``` Use the past tense or the present tense a non-imperative mood, referring to what's changed compared to the last released version of this project. --- tests/test_run_app.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/tests/test_run_app.py b/tests/test_run_app.py index bea5b1fa1ef..dc2d791ad1f 100644 --- a/tests/test_run_app.py +++ b/tests/test_run_app.py @@ -646,15 +646,14 @@ def test_run_app_preexisting_inet6_socket( @skip_if_no_unix_socks def test_run_app_preexisting_unix_socket( - patched_loop: asyncio.AbstractEventLoop, mocker: MockerFixture + patched_loop: asyncio.AbstractEventLoop, unix_sockname: str, mocker: MockerFixture ) -> None: app = web.Application() - sock_path = "/tmp/test_preexisting_sock1" sock = socket.socket(socket.AF_UNIX) with contextlib.closing(sock): - sock.bind(sock_path) - os.unlink(sock_path) + sock.bind(unix_sockname) + os.unlink(unix_sockname) printer = mock.Mock(wraps=stopper(patched_loop)) web.run_app(app, sock=sock, print=printer, loop=patched_loop) @@ -662,7 +661,7 @@ def test_run_app_preexisting_unix_socket( patched_loop.create_server.assert_called_with( # type: ignore[attr-defined] mock.ANY, sock=sock, backlog=128, ssl=None ) - assert f"http://unix:{sock_path}:" in printer.call_args[0][0] + assert f"http://unix:{unix_sockname}:" in printer.call_args[0][0] def test_run_app_multiple_preexisting_sockets(