https://pantsbuild.org/ logo
#general
Title
# general
c

clean-night-52582

04/12/2021, 10:00 PM
Is there a good way to block network request within a test in pants? We want to force dev's to always mock things out and was wondering if there was a easy way to do this. The concern is that building the pytest pex file could reach out over network so would fail.
f

fast-nail-55400

04/13/2021, 12:02 AM
h

hundreds-father-404

04/13/2021, 12:03 AM
That looks promising. I don't know of any way for Pants itself to turn off network access
f

fast-nail-55400

04/13/2021, 5:04 AM
another way would be to use the
sys.audit
mechanism to trap socket audit events and raise an exception to abort the operation. https://docs.python.org/3/library/sys.html#sys.addaudithook
👍 1
c

clean-night-52582

04/13/2021, 1:59 PM
This is perfect
5 Views