diff options
author | Torsten Marek <shlomme@gmail.com> | 2014-11-09 22:44:59 +0100 |
---|---|---|
committer | Torsten Marek <shlomme@gmail.com> | 2014-11-09 22:44:59 +0100 |
commit | f5952d500ca1052252a0d8699be7ca3cf8e4eeda (patch) | |
tree | 24950b435ecabac9e22f1a22ce03de980dcd231a /astroid/test_utils.py | |
parent | 7b8f664cf8aa5e8f2e7f444b2274ae62b6390e1c (diff) | |
download | astroid-f5952d500ca1052252a0d8699be7ca3cf8e4eeda.tar.gz |
Merge all test data into a single package per Python version.
Also modernized a lot of test code. This makes it possible to run the
tests from both the base directory of the project as well as the
astroid package.
Since the packages have the same name for Python 2 and 3, there is less
version-dependent code in the tests.
Diffstat (limited to 'astroid/test_utils.py')
-rw-r--r-- | astroid/test_utils.py | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/astroid/test_utils.py b/astroid/test_utils.py index 5fc31d6..19bd7b9 100644 --- a/astroid/test_utils.py +++ b/astroid/test_utils.py @@ -157,9 +157,9 @@ def extract_node(code, module_name=''): if requested_lines: for line in requested_lines: extracted.append(_find_statement_by_line(tree, line)) - else: - # Modifies the tree. - extracted = list(_extract_expressions(tree)) + + # Modifies the tree. + extracted.extend(_extract_expressions(tree)) if not extracted: extracted.append(tree.body[-1]) @@ -171,17 +171,19 @@ def extract_node(code, module_name=''): return extracted -def build_module(code, module_name=''): +def build_module(code, module_name='', path=None): """Parses a string module with a builder. :param code: The code for the module. :type code: str :param module_name: The name for the module :type module_name: str + :param path: The path for the module + :type module_name: str :returns: The module AST. :rtype: astroid.bases.NodeNG """ code = textwrap.dedent(code) - return builder.AstroidBuilder(None).string_build(code, modname=module_name) + return builder.AstroidBuilder(None).string_build(code, modname=module_name, path=path) def require_version(minver=None, maxver=None): |