-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
base: main
Are you sure you want to change the base?
chore(ci): disable external network calls #13142
Conversation
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]>
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. |
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. |
Probably not! That's not something I've encountered needing before. Since the plugin hooks into Python's
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! |
Just so people are aware: I do plan on picking up this PR at some point. However, I'll likely do that during my larger effort to refactor the test suite. Enforcing that tests do not access the network unless allowed to would be one piece of the project. In addition, I'd like to upstream a change so |
So I have a draft PR to add subprocess support to pytest-socket. miketheman/pytest-socket#409 However, this isn't quite enough for pytest-socket to intercept all our network calls as the functional tests actually do their work in their own virtual environment. This isn't something pytest-socket can easily support. To work around this, we need to inject pytest-socket into those environments (and probably delete its In other words, there is still a fair bit of work left here :) |
As some tests spin up a local server, allow clients to communicate with
local addresses only.
Refs: https://pypi.org/project/pytest-socket/