我有服务/读取一些数据的客户端和服务器脚本。
当我尝试使用 PyUnit 编写单元测试时,会出现一个我无法推理的错误。
这是相关的代码片段:
class TestSequenceFunctions(unittest.TestCase):
def setUp(self):
#some set up operations
def testRecieve(self):
s = socket.socket()
s.connect((FEED_SERVER_HOST, FEED_SERVER_PORT))
sock = socket.socket()
#some recieve operations
s.close()
# When i write this code snippet below, i get error: [Errno 98] Address already in use
error. I tried closing 's' socket in tearDown function but still same error raising.
def testAnotherRecieve(self):
sock = socket.socket() # Results ERRNO 98.
总而言之,我无法在 unittest 类中创建第二个套接字。什么可能导致此错误?