How to start telnet server and run a test?

Hi all, wrote a script to connect to telnet, I want to test it but there is one problem, the test I wrote, but the test stops setUpClass and then does nothing, here is the test code
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import unittest
import SocketServer
from argparse import Namespace
from telnetsrv.threaded import TelnetHandler, command

from app.telnet import telnet

def args(cmd, host='localhost', user='a', password='a', port=10023):
 return Namespace(host=host, user=user, password=password, cmd=cmd, port=port)

class TelnetServer(SocketServer.TCPServer):
 allow_reuse_address = True

class MyHandler(TelnetHandler):
 def version(self, params):

 authNeedUser = True
 authNeedPass = True

 def authCallback(self, username, password):
 if user_name != the "a" or password != 'a':
 raise runtime error('Wrong password!')

class TelnetTest(unittest.TestCase):

 def setUpClass(cls):
 cls.server = TelnetServer (('localhost', 10023), MyHandler)
 except KeyboardInterrupt:
 print("Exiting telnet server")

 def tearDownClass(cls):

 def test_telnet(self):
 res = telnet(args("version"))
 print( )
 self.assertEqual(1, 1)

if __name__ == "__main__":

as you can see I first want to understand the server and then run the test, it must be done in a single test
ie the problem is this, I run the test it creates the server and everything and hangs if you try to make a connection to the server from another terminal, everything is OK, but how to make it all in one script?, I tried to do so

ie to run in a separate thread, but no result, I ask is not very to blame as the Python began to study not so long ago)))
June 10th 19 at 15:00
0 answer

Find more questions by tags Modular testingTelnetTesting softwarePython