Testing python package bin scripts best practice -
myproject/ bin/ myscript mypackage/ __init__.py core.py tests/ __init__.py test_mypackage.py setup.py what best way test script myscript?
from research, seems answer i've found write test in tests called test_myscript , use like
import subprocess process = subprocess.popen('myscript arg1 arg2') print process.communicate() in test case run script , test results. there better way? or other suggestions different ways? , should put test suite in bin/tests or in mypackage/tests?
i don't believe there "best practices" put tests. see how many different opinions there: where python unit tests go?
i'd have 1 , tests directory on top-level, near bin , mypackage directories - as, example, django has.
for running bin script , getting results can use:
subprocess (as you've mentioned), using
check_output:import subprocess output = subprocess.check_output("cat /etc/services", shell=true)-
- was designed
test command-line scripts- looks tool job - also see article
- was designed
- cli , it's cli.test module (haven't ever used personally)
hope helps.
Comments
Post a Comment