Pythonunit test: output after execution of the test should be displayed in the log

41 views Asked by At

Used packages:

Paramiko and Unittest

Details

A somewhat special question that is probably quite easy to answer. I am currently testing the functionality on a cmd level with a unit test. In this test case, a cmd command is listed on a switch on the one hand "q = self.s.query ('clock-source local')". This sets the clock source function to local or NTP. The test works.

Another command (show daylight) generates an overview which shows me the time and further information. I would like to see this in the logged streaming and in the log file.

    def test_enable_clock_source_local(self):
    logger_true.info('test_enable_clock_source_local')
    if self.s.loggedin:
        logger.info('self.s.loggedin')
        q = self.s.query('time')
        logger.info('time')
        self.assertIsNotNone(q, 'missing answer')
        self.assertEqual('\r\n', q, 'unexpected result')
        logger.info('missing answer')
        logger.info('unexpected result')

        # switch to prompt account

        q = self.s.query('clock-source local')
        logger.info('clock-source local')
        q = self.s.query('exit')
        self.assertIsNotNone(q, 'missing answer')
        self.assertEqual('\r\n', q, 'unexpected result')
        logger.info('missing answer')
        logger.info('unexpected result')

Clock Source          : NTP Server
Local Time            : 2011-01-05 02:53:24  (YYYY-MM-DD HH:MM:SS)
Time Zone Offset      : 60 (min)
Daylight Savings      : Enabled
Time Set Offset       : 60 (min)
Daylight Savings Type : Recurring
From                  : Day:Sun Week:Last  Month:Mar Time:02:00
To                    : Day:Sun Week:Last  Month:Oct Time:03:00

Question:

Which command can I use accordingly to let me show this in the log or in the straming handler. And will this be formatted accordingly?

0

There are 0 answers