-
-
Notifications
You must be signed in to change notification settings - Fork 28.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Block tests from opening sockets (#55516)
- Loading branch information
1 parent
a8b7c52
commit f6682ba
Showing
10 changed files
with
135 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
"""Test configuration for auth.""" | ||
import pytest | ||
|
||
|
||
@pytest.fixture | ||
def aiohttp_client(loop, aiohttp_client, socket_enabled): | ||
"""Return aiohttp_client and allow opening sockets.""" | ||
return aiohttp_client |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
"""Test configuration for http.""" | ||
import pytest | ||
|
||
|
||
@pytest.fixture | ||
def aiohttp_client(loop, aiohttp_client, socket_enabled): | ||
"""Return aiohttp_client and allow opening sockets.""" | ||
return aiohttp_client |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
"""Test test fixture configuration.""" | ||
import socket | ||
|
||
import pytest | ||
import pytest_socket | ||
|
||
|
||
def test_sockets_disabled(): | ||
"""Test we can't open sockets.""" | ||
with pytest.raises(pytest_socket.SocketBlockedError): | ||
socket.socket() | ||
|
||
|
||
def test_sockets_enabled(socket_enabled): | ||
"""Test we can't connect to an address different from 127.0.0.1.""" | ||
mysocket = socket.socket() | ||
with pytest.raises(pytest_socket.SocketConnectBlockedError): | ||
mysocket.connect(("127.0.0.2", 1234)) |