Skip to content

Commit

Permalink
Merge pull request #1054 from Sage-Bionetworks/bwmac/allow_socket_con…
Browse files Browse the repository at this point in the history
…nections_windows

[SYNPY-1344] Allows Socket Connections for Windows Systems in Unit Tests
  • Loading branch information
BWMac authored Jan 25, 2024
2 parents d457d35 + ed499cc commit 7255988
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions tests/unit/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,17 @@ def pytest_runtest_setup():
allow_unix_socket=True is required for async to work.
"""
disable_socket(allow_unix_socket=True)
# This is a work-around because of https://github.com/python/cpython/issues/77589
if platform.system() != "Windows":
disable_socket(allow_unix_socket=True)


def test_confirm_connections_blocked():
"""Confirm that socket connections are blocked during unit tests."""
with pytest.raises(SocketBlockedError) as cm_ex:
urllib.request.urlopen("http://example.com")
assert "A test tried to use socket.socket." == str(cm_ex.value)
if platform.system() != "Windows":
with pytest.raises(SocketBlockedError) as cm_ex:
urllib.request.urlopen("http://example.com")
assert "A test tried to use socket.socket." == str(cm_ex.value)


@pytest.fixture(autouse=True)
Expand Down

0 comments on commit 7255988

Please sign in to comment.