Python:OSERROR套接字后重新连接Unitest

时间:2018-08-21 07:37:28

标签: python python-3.x python-2.7 sockets python-requests

在测试中,经过几次传递后,我收到了套接字错误。

OSError:套接字已关闭

因为显然在您必须查看位置之前,连接已中断,但是在进行各种测试后仍无法确定。

class SwitchAccount(unittest.TestCase):    #This class inherits unittest.TestCase
    def setUp(self):

        self.s = SSH(host='xxx.xx.xx.xxx', username='xxx', password='xxx')
        self.s.query_interactive = True

    def test_accounting_disable(self):

                if self.s.login():
                  q = self.s.query('aaa') #Accounting
                  q = self.s.query('accounting disable') #run function
                  q = self.s.query('exit')


    def test_account_enable(self):
                if self.s.login():
                  q = self.s.query('aaa')  # Accounting
                  q = self.s.query('accounting enable') # run function
                  q = self.s.query('exit')


======================================================================
ERROR: test_delete_user (__main__.SwitchAccount)
----------------------------------------------------------------------

    raise socket.error('Socket is closed')
OSError: Socket is closed

0 个答案:

没有答案