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: remove post-yield behaviors #90

Merged
merged 2 commits into from Dec 21, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 4 additions & 5 deletions pytest_socket.py
Expand Up @@ -65,15 +65,13 @@ def socket_disabled(pytestconfig):
""" disable socket.socket for duration of this test function """
disable_socket(allow_unix_socket=pytestconfig.__socket_allow_unix_socket)
yield
enable_socket()


@pytest.fixture
def socket_enabled(pytestconfig):
""" enable socket.socket for duration of this test function """
enable_socket()
yield
disable_socket(allow_unix_socket=pytestconfig.__socket_allow_unix_socket)


def disable_socket(allow_unix_socket=False):
Expand Down Expand Up @@ -126,7 +124,7 @@ def pytest_runtest_setup(item):


def pytest_runtest_teardown():
remove_host_restrictions()
_remove_restrictions()


def host_from_address(address):
Expand Down Expand Up @@ -159,7 +157,8 @@ def guarded_connect(inst, *args):
socket.socket.connect = guarded_connect


def remove_host_restrictions():
""" restore socket.socket.connect() to allow access to the Internet. useful in testing.
def _remove_restrictions():
""" restore socket.socket.* to allow access to the Internet. useful in testing.
"""
socket.socket = _true_socket
socket.socket.connect = _true_connect