tests: select available TCP port#994
Conversation
Merging this PR will not alter performance
Comparing Footnotes
|
Kludex
left a comment
There was a problem hiding this comment.
Can you try what I commented, please? If it doesn't work, this is fine.
| @pytest.fixture(scope="session") | ||
| def server() -> typing.Iterator[TestServer]: | ||
| config = Config(app=app, lifespan="off", loop="asyncio") | ||
| config = Config(app=app, lifespan="off", loop="asyncio", port=0) |
There was a problem hiding this comment.
I think we can avoid port=0 and the introspection of servers object in Uvicorn if we use free_tcp_port, and then we can use self.config.port.
| config = Config(app=app, lifespan="off", loop="asyncio", port=0) | |
| config = Config(app=app, lifespan="off", loop="asyncio", port=free_tcp_port) |
If TCP port 8000 is in use on the developers' machine, the tests hang. It is mentioned in the CONTRIBUTING.md but it is not great developer experience. Let's instead select a random free port in uvicorn. Fixes pydantic#681
d74afa1 to
e11dcfe
Compare
I was able to make it work but only using |
Summary
If TCP port 8000 is in use on the developers' machine, the tests hang. It is mentioned in the CONTRIBUTING.md but it is not great developer experience.
Let's instead select a random free port by specifying port=0 in uvicorn.
Fixes #681
Checklist