tests: better logging for all testcases

This commit is contained in:
Nick 2018-06-18 14:15:01 +02:00
parent ecf63b992b
commit ae360073bf
2 changed files with 10 additions and 7 deletions

View File

@ -8,6 +8,7 @@ The asynchronous server is a high performance implementation using the
twisted library as its backend. This allows it to scale to many thousands
of nodes which can be helpful for testing monitoring software.
'''
import logging
#---------------------------------------------------------------------------#
# import the various server implementations
#---------------------------------------------------------------------------#
@ -26,10 +27,7 @@ class ModbusSerialServer:
#---------------------------------------------------------------------------#
# configure the service logging
#---------------------------------------------------------------------------#
import logging
logging.basicConfig()
log = logging.getLogger()
log.setLevel(logging.DEBUG)
log = logging.getLogger("ModbusServer")
serialPort = readlink('/tmp/pts1')
@ -126,9 +124,8 @@ class ModbusSerialServer:
self.p.start()
print("p.start done")
def kill(self):
print("Going to terminate the process, this could throw exceptions")
self.log.info("Going to terminate the process, this could throw exceptions")
if self.p is not None:
self.p.terminate()

View File

@ -106,4 +106,10 @@ class TestModbusRequests(unittest.TestCase):
if __name__ == '__main__':
unittest.main()
import logging
stdout_handler = logging.StreamHandler(sys.stdout)
logging.basicConfig(level=logging.DEBUG,
format=u'[%(asctime)s] %(name)-26s-%(levelname)-5s %(funcName)-20s:%(lineno)-4d \033[35m%(message)s\033[0m',
datefmt='%d.%m. %H:%M:%S',
handlers=[stdout_handler])
unittest.main(verbosity=2)