diff options
author | Brett Cannon <brett@python.org> | 2012-02-17 10:44:24 -0500 |
---|---|---|
committer | Brett Cannon <brett@python.org> | 2012-02-17 10:44:24 -0500 |
commit | 082f177c67d8dc7edd16dd5db764e28f5a0795f1 (patch) | |
tree | ad3da4373ce608232060845f36598999524c78c7 /Lib/importlib/test | |
parent | f2e86751cc50024570433655898f57f4f298d9fa (diff) | |
download | cpython-git-082f177c67d8dc7edd16dd5db764e28f5a0795f1.tar.gz |
Fix importlib.test.__main__ to only worry about command-line flags when directly executed.
Diffstat (limited to 'Lib/importlib/test')
-rw-r--r-- | Lib/importlib/test/__main__.py | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/Lib/importlib/test/__main__.py b/Lib/importlib/test/__main__.py index 55158126da..92171b25ca 100644 --- a/Lib/importlib/test/__main__.py +++ b/Lib/importlib/test/__main__.py @@ -4,7 +4,6 @@ Specifying the ``--builtin`` flag will run tests, where applicable, with builtins.__import__ instead of importlib.__import__. """ -import argparse from importlib.test.import_ import util import os.path from test.support import run_unittest @@ -12,13 +11,6 @@ import unittest def test_main(): - parser = argparse.ArgumentParser(description='Execute the importlib test ' - 'suite') - parser.add_argument('-b', '--builtin', action='store_true', default=False, - help='use builtins.__import__() instead of importlib') - args = parser.parse_args() - if args.builtin: - util.using___import__ = True start_dir = os.path.dirname(__file__) top_dir = os.path.dirname(os.path.dirname(start_dir)) test_loader = unittest.TestLoader() @@ -26,4 +18,13 @@ def test_main(): if __name__ == '__main__': + import argparse + + parser = argparse.ArgumentParser(description='Execute the importlib test ' + 'suite') + parser.add_argument('-b', '--builtin', action='store_true', default=False, + help='use builtins.__import__() instead of importlib') + args = parser.parse_args() + if args.builtin: + util.using___import__ = True test_main() |