More generic approach to ignore python tests requiring network access?

Integration testing against a mocked local web server is a common pattern in python packages. My understanding is that such tests work in sandboxed builds linux, but not mac since mac does not have an equivalent feature to network namespace. Currently the python-modules have a lot of mac specific test exclusions to work around this.

Is a more generic approach to this possible? Most of these tests ultimately fail on some call to python’s socket library. Would it be possible to xfail any test that does this using a monkeypatch?