Add similar mock #326
-
I like this package, but now I need to only disable internet in part of my test - this way I can test if a certain caching method indeed prevents requests to pages, and thus will work when connection fails. I don't find in the docs if this is supported?
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
While we don't yet have the exact behavior you're describing (using the Here's an example: from pytest_socket import disable_socket, enable_socket
...
def test_something()
# This runs with internet
...
disable_socket()
# This runs without
...
enable_socket()
# This should run with
... If you'd like to submit a patch with tests that implements the context manager protocol that does this, that'd be great! |
Beta Was this translation helpful? Give feedback.
While we don't yet have the exact behavior you're describing (using the
with
context manager), you can likely accomplish this by calling the disable/enable functions directly.Here's an example:
If you'd like to submit a patch with tests that implements the context manager protocol that does this, that'd be great!