Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bogus test failure in test_open_unix_socket due to use of an insufficiently unique name #447

Closed
njsmith opened this issue Feb 21, 2018 · 0 comments · Fixed by #448
Closed

Comments

@njsmith
Copy link
Member

njsmith commented Feb 21, 2018

Seen here: https://ci.cryptography.io/blue/rest/organizations/jenkins/pipelines/python-trio/pipelines/trio/branches/PR-446/runs/1/nodes/5/log/?start=0

____________________________ test_open_unix_socket _____________________________

    async def test_open_unix_socket():
>       name, serv_sock = await get_server_socket()

../.venv/lib/python3.5/site-packages/trio/tests/test_highlevel_open_unix_stream.py:50: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

    async def get_server_socket():
        name = Path() / tempfile.gettempdir() / "test.sock"
        try:
            await name.unlink()
        except OSError:
            pass
    
        serv_sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
>       serv_sock.bind(fspath(name))  # bpo-32562
E       OSError: [Errno 48] Address already in use

../.venv/lib/python3.5/site-packages/trio/tests/test_highlevel_open_unix_stream.py:24: OSError
njsmith added a commit to njsmith/trio that referenced this issue Feb 21, 2018
The main substantive change here is switching to using mktemp() to
pick a server socket name, instead of using the fixed name
"/tmp/test.sock". This should fix python-triogh-447.

While I was at it, I also refactored the main test, and made it clean
up after itself more carefully.

Finally, I replaced

   os.path.join(tempfile.gettempdir(), tempfile.mktemp())

with

   tempfile.mktemp()

Because it turns out they're equivalent: mktemp() already returns an
absolute filename inside an appropriate directory.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant