简体   繁体   中英

Pysys. Using Pysys' log on different modules

I'd like to use PySys' log from other modules of my testing framework in order to keep all the activity from the testcase's execution in the same place (run.log). The approach followed was to include the next statement

from pysys import log

and using the log object for writing traces from the additional components of our testing framework

class MyClass:
  def logSomething(self):
      log.info("Something to log")
...

But what I got is the duplication of the lines of the log in the following way:

2016-05-03 15:15:37,750 INFO  Test final outcome BLOCKED
INFO:pysys:Test final outcome BLOCKED
2016-05-03 15:15:37,750 INFO
INFO:pysys:
2016-05-03 15:15:37,851 CRIT
CRIT:pysys:
2016-05-03 15:15:37,851 CRIT  Test duration: 41.06 (secs)
CRIT:pysys:Test duration: 41.06 (secs)

I understand that I'm doing something not properly, so any feedback about that could be appreciated.

Thanks.

Just doing a simple test, if I have a base test with the below;

from pysys.constants import *
from pysys.basetest import BaseTest
from myclass import MyClass

    class PySysTest(BaseTest):
        def execute(self):
            myclass = MyClass()
            myclass.logSomething()

        def validate(self):
            pass

the output is see is;

2016-05-03 15:38:07,125 INFO  ==============================================================
2016-05-03 15:38:07,127 INFO  Id   : test_001
2016-05-03 15:38:07,128 INFO  ==============================================================
2016-05-03 15:38:07,134 INFO  Something to log
2016-05-03 15:38:07,135 INFO
2016-05-03 15:38:07,137 INFO  Test duration: 0.01 secs
2016-05-03 15:38:07,137 INFO  Test final outcome:  NOT VERIFIED
2016-05-03 15:38:07,138 INFO

So there may be something else going on elsewhere in your code causing the multiple messages. Are you able to post any more detailed examples of your code to this ticket to help investigate?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM