diff options
author | Zachary Turner <zturner@google.com> | 2015-11-05 19:22:28 +0000 |
---|---|---|
committer | Zachary Turner <zturner@google.com> | 2015-11-05 19:22:28 +0000 |
commit | c1b7cd72db41c14a4f8d7df2c06bc908e2f0bae5 (patch) | |
tree | ab8840e262dc2d898cb8df2eb36ebbe7b427b527 /lldb/packages/Python/lldbsuite/test/dotest.py | |
parent | 185a7aaddacff4b7c846b5946c244d6fabdefa32 (diff) | |
download | bcm5719-llvm-c1b7cd72db41c14a4f8d7df2c06bc908e2f0bae5.tar.gz bcm5719-llvm-c1b7cd72db41c14a4f8d7df2c06bc908e2f0bae5.zip |
Python 3 - Turn on absolute imports, and fix existing imports.
Absolute imports were introduced in Python 2.5 as a feature
(e.g. from __future__ import absolute_import), and made default
in Python 3.
When absolute imports are enabled, the import system changes in
a couple of ways:
1) The `import foo` syntax will *only* search sys.path. If `foo`
isn't in sys.path, it won't be found. Period. Without absolute
imports, the import system will also search the same directory
that the importing file resides in, so that you can easily
import from the same folder.
2) From inside a package, you can use a dot syntax to refer to higher
levels of the current package. For example, if you are in the
package lldbsuite.test.utility, then ..foo refers to
lldbsuite.test.foo. You can use this notation with the
`from X import Y` syntax to write intra-package references. For
example, using the previous locationa s a starting point, writing
`from ..support import seven` would import lldbsuite.support.seven
Since this is now the default behavior in Python 3, this means that
importing from the same directory with `import foo` *no longer works*.
As a result, the only way to have portable code is to force absolute
imports for all versions of Python.
See PEP 0328 [https://www.python.org/dev/peps/pep-0328/] for more
information about absolute and relative imports.
Differential Revision: http://reviews.llvm.org/D14342
Reviewed By: Todd Fiala
llvm-svn: 252191
Diffstat (limited to 'lldb/packages/Python/lldbsuite/test/dotest.py')
-rw-r--r-- | lldb/packages/Python/lldbsuite/test/dotest.py | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/lldb/packages/Python/lldbsuite/test/dotest.py b/lldb/packages/Python/lldbsuite/test/dotest.py index aec1762a729..0799ac789de 100644 --- a/lldb/packages/Python/lldbsuite/test/dotest.py +++ b/lldb/packages/Python/lldbsuite/test/dotest.py @@ -18,16 +18,14 @@ Type: for available options. """ +from __future__ import absolute_import from __future__ import print_function -import sys - -import lldbsuite -import lldbtest_config +# System modules +import sys import atexit import importlib import os -import dotest_args import errno import platform import progress @@ -35,14 +33,20 @@ import signal import socket import subprocess import sys -import test_results -from test_results import EventBuilder import inspect -import unittest2 -import test_categories +# Third-party modules import six -import lldbsuite.support.seven as seven +import unittest2 + +# LLDB Modules +import lldbsuite +from . import dotest_args +from . import lldbtest_config +from . import test_categories +from . import test_results +from .test_results import EventBuilder +from ..support import seven def is_exe(fpath): """Returns true if fpath is an executable.""" @@ -1470,7 +1474,7 @@ def run_suite(): # If we are running as the multiprocess test runner, kick off the # multiprocess test runner here. if isMultiprocessTestRunner(): - import dosep + from . import dosep dosep.main(output_on_success, num_threads, multiprocess_test_subdir, test_runner_name, results_formatter_object) raise Exception("should never get here") |