| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 1554b18 commit 445448c
3 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2611,27 +2611,31 @@ def get(self): | |||
| 2611 | 2611 | """, | |
| 2612 | 2612 | } | |
| 2613 | 2613 | ||
| 2614 | + | ||
| 2614 | 2615 | def _test(): | |
| 2615 | 2616 | testfiles = [arg for arg in sys.argv[1:] if arg and arg[0] != '-'] | |
| 2616 | - if testfiles: | ||
| 2617 | - for filename in testfiles: | ||
| 2618 | - if filename.endswith(".py"): | ||
| 2619 | - # It is a module -- insert its dir into sys.path and try to | ||
| 2620 | - # import it. If it is part of a package, that possibly won't work | ||
| 2621 | - # because of package imports. | ||
| 2622 | - dirname, filename = os.path.split(filename) | ||
| 2623 | - sys.path.insert(0, dirname) | ||
| 2624 | - m = __import__(filename[:-3]) | ||
| 2625 | - del sys.path[0] | ||
| 2626 | - failures, _ = testmod(m) | ||
| 2627 | - else: | ||
| 2628 | - failures, _ = testfile(filename, module_relative=False) | ||
| 2629 | - if failures: | ||
| 2630 | - return 1 | ||
| 2631 | - else: | ||
| 2632 | - r = unittest.TextTestRunner() | ||
| 2633 | - r.run(DocTestSuite()) | ||
| 2617 | + if not testfiles: | ||
| 2618 | + name = os.path.basename(sys.argv[0]) | ||
| 2619 | + if '__loader__' in globals() and name.endswith('.py'): # python -m | ||
| 2620 | + name, _ = os.path.splitext(name) | ||
| 2621 | + print("usage: {0} [-v] file ...".format(name)) | ||
| 2622 | + return 2 | ||
| 2623 | + for filename in testfiles: | ||
| 2624 | + if filename.endswith(".py"): | ||
| 2625 | + # It is a module -- insert its dir into sys.path and try to | ||
| 2626 | + # import it. If it is part of a package, that possibly | ||
| 2627 | + # won't work because of package imports. | ||
| 2628 | + dirname, filename = os.path.split(filename) | ||
| 2629 | + sys.path.insert(0, dirname) | ||
| 2630 | + m = __import__(filename[:-3]) | ||
| 2631 | + del sys.path[0] | ||
| 2632 | + failures, _ = testmod(m) | ||
| 2633 | + else: | ||
| 2634 | + failures, _ = testfile(filename, module_relative=False) | ||
| 2635 | + if failures: | ||
| 2636 | + return 1 | ||
| 2634 | 2637 | return 0 | |
| 2635 | 2638 | ||
| 2639 | + | ||
| 2636 | 2640 | if __name__ == "__main__": | |
| 2637 | 2641 | sys.exit(_test()) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -125,7 +125,7 @@ def _run_module_as_main(mod_name, alter_argv=True): | |||
| 125 | 125 | ||
| 126 | 126 | Note that the executed module will have full access to the | |
| 127 | 127 | __main__ namespace. If this is not desirable, the run_module() | |
| 128 | - function sbould be used to run the module code in a fresh namespace. | ||
| 128 | + function should be used to run the module code in a fresh namespace. | ||
| 129 | 129 | ||
| 130 | 130 | At the very least, these variables in __main__ will be overwritten: | |
| 131 | 131 | __name__ | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -511,6 +511,9 @@ Documentation | |||
| 511 | 511 | Tests | |
| 512 | 512 | ----- | |
| 513 | 513 | ||
| 514 | + - Issue #7376: instead of running a self-test (which was failing) when called | ||
| 515 | + with no arguments, doctest.py now gives a usage message. | ||
| 516 | + | ||
| 514 | 517 | - Issue #7396: fix regrtest -s, which was broken by the -j enhancement. | |
| 515 | 518 | ||
| 516 | 519 | - Issue #7498: test_multiprocessing now uses test.support.find_unused_port | |
| Back | FazBrowse Home | New Git URL |
0 commit comments