Restore original socket after test execution of test_check_connect (#19)

This commit is contained in:
sturmianseq 2021-12-27 20:18:25 +08:00 committed by GitHub
parent 4a1c2f15f7
commit e6e4055f81
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 0 deletions

View File

@ -50,8 +50,10 @@ def test_check_connect(port=None):
def mock_socket(*args): def mock_socket(*args):
raise socket.error raise socket.error
old_socket = pydu.request.socket.socket
pydu.request.socket.socket = mock_socket pydu.request.socket.socket = mock_socket
assert not check_connect('127.0.0.1', port=port, timeout=0.01) assert not check_connect('127.0.0.1', port=port, timeout=0.01)
pydu.request.socket.socket = old_socket
def test_update_query_params(): def test_update_query_params():