简体   繁体   中英

How can i use nosetest to run an shell script or another python script

nose

is a test runner which extends PyUnit. Is it possible to write eg

$ nosetests --with-shell myTest.py -myargs test

If not, then is there a plugin, or do i need to develop it myself. Any suggestions ?

Nose is not a general test harness. It's specifically a Python harness which runs Python unit tests.

So, while you can write extensions for it to execute scripts and mark them as successes or failures based on the exit status or an output string, I think it's an attempt to shoehorn the harness into doing something it's not really meant to do.

You should package your tests as Python functions or classes and then have them use a library to run external scripts the output or behaviour of which is translated into something that nose can interpret rather than extend nose to directly run scripts.

Also, I've experimented with nose a bit and found it's extension mechanism quite clumsy compared to py.test . You might want to give that a shot.

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