MCPcopy Index your code
hub / github.com/RustPython/RustPython / test

Function test

Lib/modulefinder.py:608–664  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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

Callers 1

modulefinder.pyFile · 0.70

Calls 9

import_hookMethod · 0.95
load_fileMethod · 0.95
run_scriptMethod · 0.95
reportMethod · 0.95
reprFunction · 0.85
ModuleFinderClass · 0.85
printFunction · 0.50
splitMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected