Move main src/sorting/scaling.py code into main() function.
authorW. Trevor King <wking@drexel.edu>
Mon, 25 Oct 2010 13:55:25 +0000 (09:55 -0400)
committerW. Trevor King <wking@drexel.edu>
Mon, 25 Oct 2010 13:55:25 +0000 (09:55 -0400)
src/sorting/scaling.py

index 5af9a8cc2f944ab40ebc0818f3093c0ca18610d6..c553ee4964111238084b678ad7d78ea39be7f8b5 100755 (executable)
@@ -65,11 +65,13 @@ def run_tests(executable, stdin=True, data_file=None, ordered=False,
         N *= 2
     return times
 
-
-if __name__ == '__main__':
+def main(argv=None):
     import optparse
     import tempfile
 
+    if argv == None:
+        argv = sys.argv[1:]
+
     p = optparse.OptionParser(
         usage='%prog [options] executable', epilog=__doc__)
     p.add_option('-s', '--stdin', dest='stdin', default=False,
@@ -81,7 +83,7 @@ if __name__ == '__main__':
     p.add_option('-p', '--plot', dest='plot', default=None,
                  help='Filename for a scaling plot (no plot is generated if this option is not set).')
 
-    options,args = p.parse_args()
+    options,args = p.parse_args(argv)
 
     executable = args[0]
 
@@ -135,3 +137,6 @@ if __name__ == '__main__':
         a.set_ylabel('t (s)')
         a.legend(loc='best')
         f.savefig(options.plot)
+
+if __name__ == '__main__':
+    main()