()
| 615 | |
| 616 | |
| 617 | def test(): |
| 618 | # Parse command line |
| 619 | import getopt |
| 620 | try: |
| 621 | opts, args = getopt.getopt(sys.argv[1:], "dmp:qx:") |
| 622 | except getopt.error as msg: |
| 623 | print(msg) |
| 624 | return |
| 625 | |
| 626 | # Process options |
| 627 | debug = 1 |
| 628 | domods = 0 |
| 629 | addpath = [] |
| 630 | exclude = [] |
| 631 | for o, a in opts: |
| 632 | if o == '-d': |
| 633 | debug = debug + 1 |
| 634 | if o == '-m': |
| 635 | domods = 1 |
| 636 | if o == '-p': |
| 637 | addpath = addpath + a.split(os.pathsep) |
| 638 | if o == '-q': |
| 639 | debug = 0 |
| 640 | if o == '-x': |
| 641 | exclude.append(a) |
| 642 | |
| 643 | # Provide default arguments |
| 644 | if not args: |
| 645 | script = "hello.py" |
| 646 | else: |
| 647 | script = args[0] |
| 648 | |
| 649 | # Set the path based on sys.path and the script directory |
| 650 | path = sys.path[:] |
| 651 | path[0] = os.path.dirname(script) |
| 652 | path = addpath + path |
| 653 | if debug > 1: |
| 654 | print("path:") |
| 655 | for item in path: |
| 656 | print(" ", repr(item)) |
| 657 | |
| 658 | # Create the module finder and turn its crank |
| 659 | mf = ModuleFinder(path, debug, exclude) |
| 660 | for arg in args[1:]: |
| 661 | if arg == '-m': |
| 662 | domods = 1 |
| 663 | continue |
| 664 | if domods: |
| 665 | if arg[-2:] == '.*': |
| 666 | mf.import_hook(arg[:-2], None, ["*"]) |
| 667 | else: |
| 668 | mf.import_hook(arg) |
| 669 | else: |
| 670 | mf.load_file(arg) |
| 671 | mf.run_script(script) |
| 672 | mf.report() |
| 673 | return mf # for -i debugging |
| 674 |
no test coverage detected
searching dependent graphs…