O'Reilly logo

Python Testing Cookbook. by Bhaskar N. Das, Greg L. Turnquist

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

How to do it...

With the following steps, we will create a project-level script that will run all the test recipes from this chapter:

  1. Create a new file called recipe34.py.
  2. Add code that uses the getopt library for parsing command-line arguments, as shown here:
import getoptimport logging import nose import os import os.path import re import sys import lettuce import doctestfrom glob import globdef usage():     print()    print("Usage: python recipe34.py [command]"     print()    print "\t--help"     print "\t--test"     print "\t--package"     print "\t--publish"     print "\t--register"     print()    try:      optlist, args = getopt.getopt(sys.argv[1:],                "h",              ["help", "test", "package", "publish", "register"])    except getopt.GetoptError: # print help information and exit: ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required