Skip to content

Commit b130bca

Browse files
authored
Use unix_sockname fixture for test_run_app_preexisting_unix_socket (#11498)
<!-- Thank you for your contribution! --> ## What do these changes do? Fixes the tests in sandboxed build environments where `/tmp` is not accessible. <!-- Please give a short brief about these changes. --> ## Are there changes in behavior for the user? No. <!-- Outline any notable behaviour for the end users. --> ## 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. <!-- Stop right there! Pause. Just for a minute... Can you think of anything obvious that would complicate the ongoing development of this project? Try to consider if you'd be able to maintain it throughout the next 5 years. Does it seem viable? Tell us your thoughts! We'd very much love to hear what the consequences of merging this patch might be... This will help us assess if your change is something we'd want to entertain early in the review process. Thank you in advance! --> ## Related issue number <!-- Will this resolve any open issues? --> <!-- Remember to prefix with 'Fixes' if it closes an issue (e.g. 'Fixes #123'). --> ## 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 &lt;Name&gt; &lt;Surname&gt;. * 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 `<issue_or_pr_num>.<type>.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.
1 parent 647bc64 commit b130bca

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

tests/test_run_app.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -646,23 +646,22 @@ def test_run_app_preexisting_inet6_socket(
646646

647647
@skip_if_no_unix_socks
648648
def test_run_app_preexisting_unix_socket(
649-
patched_loop: asyncio.AbstractEventLoop, mocker: MockerFixture
649+
patched_loop: asyncio.AbstractEventLoop, unix_sockname: str, mocker: MockerFixture
650650
) -> None:
651651
app = web.Application()
652652

653-
sock_path = "/tmp/test_preexisting_sock1"
654653
sock = socket.socket(socket.AF_UNIX)
655654
with contextlib.closing(sock):
656-
sock.bind(sock_path)
657-
os.unlink(sock_path)
655+
sock.bind(unix_sockname)
656+
os.unlink(unix_sockname)
658657

659658
printer = mock.Mock(wraps=stopper(patched_loop))
660659
web.run_app(app, sock=sock, print=printer, loop=patched_loop)
661660

662661
patched_loop.create_server.assert_called_with( # type: ignore[attr-defined]
663662
mock.ANY, sock=sock, backlog=128, ssl=None
664663
)
665-
assert f"http://unix:{sock_path}:" in printer.call_args[0][0]
664+
assert f"http://unix:{unix_sockname}:" in printer.call_args[0][0]
666665

667666

668667
def test_run_app_multiple_preexisting_sockets(

0 commit comments

Comments
 (0)