Writing tornado.testing.test as simple python script (and pass command line options to the testee).

I wanted to execute tornado.testing unit test with command line options(tornado.options).

Something like

python3 -m tornado.test.runtests test.py --port=8080

However I found this is impossible, because runtests tries to process options by itself. Then I tried to do this

  python3 test.py --port=8080

by putting following code at the end of the test script(test.py in this case).

if __name__ == "__main__": 
 tornado.testing.main() 

* tornado.options.parse_command_line() is called at the top of the testee's program.

This didn't work because of "AttributeError: 'module' object has no attribute 'all'" error.
So, I avoided this problem by adding "all()" function to the test.py like this, and it finally works.

def all():
    import unittest
    return unittest.defaultTestLoader.loadTestsFromNames([__name__])

Comments

Popular posts from this blog

Calling OpenCV functions via Cython from Python 3.X.

Showing CPU/Memory usage on tmux status bar(tmuxのステータスバーにCPUとMemoryの使用状況を表示する)

Subclassing and Signal connect on a same widget crashes PySide application on exit.