Fix importlib.test.__main__ to only worry about command-line flags when directly executed.
This commit is contained in:
parent
f2e86751cc
commit
082f177c67
|
@ -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()
|
||||
|
|
Loading…
Reference in New Issue