| 1 | n/a | """Run importlib's test suite. |
|---|
| 2 | n/a | |
|---|
| 3 | n/a | Specifying the ``--builtin`` flag will run tests, where applicable, with |
|---|
| 4 | n/a | builtins.__import__ instead of importlib.__import__. |
|---|
| 5 | n/a | |
|---|
| 6 | n/a | """ |
|---|
| 7 | n/a | from importlib.test.import_ import util |
|---|
| 8 | n/a | import os.path |
|---|
| 9 | n/a | from test.support import run_unittest |
|---|
| 10 | n/a | import unittest |
|---|
| 11 | n/a | |
|---|
| 12 | n/a | |
|---|
| 13 | n/a | def test_main(): |
|---|
| 14 | n/a | start_dir = os.path.dirname(__file__) |
|---|
| 15 | n/a | top_dir = os.path.dirname(os.path.dirname(start_dir)) |
|---|
| 16 | n/a | test_loader = unittest.TestLoader() |
|---|
| 17 | n/a | run_unittest(test_loader.discover(start_dir, top_level_dir=top_dir)) |
|---|
| 18 | n/a | |
|---|
| 19 | n/a | |
|---|
| 20 | n/a | if __name__ == '__main__': |
|---|
| 21 | n/a | import argparse |
|---|
| 22 | n/a | |
|---|
| 23 | n/a | parser = argparse.ArgumentParser(description='Execute the importlib test ' |
|---|
| 24 | n/a | 'suite') |
|---|
| 25 | n/a | parser.add_argument('-b', '--builtin', action='store_true', default=False, |
|---|
| 26 | n/a | help='use builtins.__import__() instead of importlib') |
|---|
| 27 | n/a | args = parser.parse_args() |
|---|
| 28 | n/a | if args.builtin: |
|---|
| 29 | n/a | util.using___import__ = True |
|---|
| 30 | n/a | test_main() |
|---|