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

chore(ci): disable external network calls #13142

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

miketheman
Copy link
Member

As some tests spin up a local server, allow clients to communicate with
local addresses only.

Refs: https://pypi.org/project/pytest-socket/

As some tests spin up a local server, allow clients to communicate with
local addresses only.

Refs: https://pypi.org/project/pytest-socket/

Signed-off-by: Mike Fiedler <[email protected]>
Not using the `network` marker as a filter - there are currently 133,
and not all of them are actually making network calls.

Signed-off-by: Mike Fiedler <[email protected]>
@ichard26
Copy link
Member

ichard26 commented Jan 3, 2025

Does this work in subprocesses? pip's functional test suite makes very heavy use of subprocesses (sometimes nested 2-3 times over). Also we use pytest-xdist, so it should work with that as well.

In general, I'm 👍 with the idea. Once the test suite is in better shape, we should enforce test hygiene by requiring tests to opt-in into external network access.

@ichard26 ichard26 added the skip news Does not need a NEWS file entry (eg: trivial changes) label Jan 3, 2025
@ichard26
Copy link
Member

ichard26 commented Jan 3, 2025

Does this work in subprocesses? pip's functional test suite makes very heavy use of subprocesses (sometimes nested 2-3 times over). Also we use pytest-xdist, so it should work with that as well.

Given that the diff only really touches the unit tests, no, it does not work in subprocesses. There are certainly many more being performed in the functional tests. This patch is probably still a good idea for our unit tests though.

@miketheman
Copy link
Member Author

Does this work in subprocesses?

Probably not! That's not something I've encountered needing before. Since the plugin hooks into Python's socket library, any subprocess is likely to not have this applied, as they'll get their own Python context. That might make this a less-valid approach for this test suite.

Also we use pytest-xdist, so it should work with that as well.

pytest-socket isn't currently tested with xdist, nor do the tests it runs test the xdist plugin, but experientially running it for warehouse over 4k+ tests works just fine.

In general, I'm 👍 with the idea. Once the test suite is in better shape, we should enforce test hygiene by requiring tests to opt-in into external network access.

Glad to hear it! This change might not be the correct implementation, given the subprocesses question. I'll mull on how this might apply to subprocesses - but if you've got some ideas, please share!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
skip news Does not need a NEWS file entry (eg: trivial changes)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants