mirror of
https://github.com/microsoft/debugpy.git
synced 2025-12-23 08:48:12 +00:00
Add socket reuse tests (#911)
* Add socket reuse tests * Address comments.
This commit is contained in:
parent
99cd1595f8
commit
52aeb0fae4
1 changed files with 31 additions and 0 deletions
31
pytests/test_socket.py
Normal file
31
pytests/test_socket.py
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
# Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
# Licensed under the MIT License. See LICENSE in the project root
|
||||
# for license information.
|
||||
|
||||
import pytest
|
||||
from ptvsd.socket import create_server, shut_down
|
||||
|
||||
|
||||
class TestSocketServerReuse(object):
|
||||
HOST1 = '127.0.0.1'
|
||||
HOST2 = '127.0.0.2'
|
||||
PORT1 = 7890
|
||||
|
||||
def test_reuse_same_address_port(self):
|
||||
try:
|
||||
sock1 = create_server(self.HOST1, self.PORT1)
|
||||
with pytest.raises(Exception):
|
||||
create_server(self.HOST1, self.PORT1)
|
||||
assert sock1.getsockname() == (self.HOST1, self.PORT1)
|
||||
finally:
|
||||
shut_down(sock1)
|
||||
|
||||
def test_reuse_same_port(self):
|
||||
try:
|
||||
sock1 = create_server(self.HOST1, self.PORT1)
|
||||
sock2 = create_server(self.HOST2, self.PORT1)
|
||||
assert sock1.getsockname() == (self.HOST1, self.PORT1)
|
||||
assert sock2.getsockname() == (self.HOST2, self.PORT1)
|
||||
finally:
|
||||
shut_down(sock1)
|
||||
shut_down(sock2)
|
||||
Loading…
Add table
Add a link
Reference in a new issue