diff options
author | Claudiu Popa <cpopa@cloudbasesolutions.com> | 2015-07-13 23:28:24 +0300 |
---|---|---|
committer | Claudiu Popa <cpopa@cloudbasesolutions.com> | 2015-07-13 23:28:24 +0300 |
commit | 1ea8e66df8e3e922900c95b08ce0ccb814437767 (patch) | |
tree | e39ec67cb66fe124364f7a310fb96a2d301a486b | |
parent | de2f313c5ca5acdb640bab62a690b95802caea62 (diff) | |
download | pylint-1ea8e66df8e3e922900c95b08ce0ccb814437767.tar.gz |
Update pylint to use the new astroid.parse, not testutils.build_module.
-rw-r--r-- | pylint/test/unittest_checker_base.py | 9 | ||||
-rw-r--r-- | pylint/test/unittest_checker_classes.py | 3 | ||||
-rw-r--r-- | pylint/test/unittest_checker_format.py | 3 | ||||
-rw-r--r-- | pylint/test/unittest_checker_python3.py | 20 | ||||
-rw-r--r-- | pylint/test/unittest_checker_variables.py | 4 | ||||
-rw-r--r-- | pylint/test/unittest_pyreverse_inspector.py | 3 | ||||
-rw-r--r-- | pylint/test/unittest_utils.py | 5 | ||||
-rw-r--r-- | pylint/testutils.py | 4 |
8 files changed, 29 insertions, 22 deletions
diff --git a/pylint/test/unittest_checker_base.py b/pylint/test/unittest_checker_base.py index b74ac5a..cd2dab2 100644 --- a/pylint/test/unittest_checker_base.py +++ b/pylint/test/unittest_checker_base.py @@ -4,6 +4,7 @@ import re import sys import unittest +import astroid from astroid import test_utils from pylint.checkers import base from pylint.testutils import CheckerTestCase, Message, set_config @@ -13,17 +14,17 @@ class DocstringTest(CheckerTestCase): CHECKER_CLASS = base.DocStringChecker def test_missing_docstring_module(self): - module = test_utils.build_module("something") + module = astroid.parse("something") with self.assertAddsMessages(Message('missing-docstring', node=module, args=('module',))): self.checker.visit_module(module) def test_missing_docstring_emtpy_module(self): - module = test_utils.build_module("") + module = astroid.parse("") with self.assertNoMessages(): self.checker.visit_module(module) def test_empty_docstring_module(self): - module = test_utils.build_module("''''''") + module = astroid.parse("''''''") with self.assertAddsMessages(Message('empty-docstring', node=module, args=('module',))): self.checker.visit_module(module) @@ -143,7 +144,7 @@ class NameCheckerTest(CheckerTestCase): with self.assertNoMessages(): self.checker.visit_assname(assign.targets[0]) - module = test_utils.build_module(""" + module = astroid.parse(""" def A(): return 1, 2, 3 CONSTA, CONSTB, CONSTC = A() diff --git a/pylint/test/unittest_checker_classes.py b/pylint/test/unittest_checker_classes.py index f21cfc1..6ada28f 100644 --- a/pylint/test/unittest_checker_classes.py +++ b/pylint/test/unittest_checker_classes.py @@ -2,6 +2,7 @@ import unittest import sys +import astroid from astroid import test_utils from pylint.checkers import classes from pylint.testutils import CheckerTestCase, Message, set_config @@ -28,7 +29,7 @@ class VariablesCheckerTC(CheckerTestCase): exclude names from protected-access warning. """ - node = test_utils.build_module(""" + node = astroid.parse(""" class Protected(object): '''empty''' def __init__(self): diff --git a/pylint/test/unittest_checker_format.py b/pylint/test/unittest_checker_format.py index 7d5a32f..2e35d4a 100644 --- a/pylint/test/unittest_checker_format.py +++ b/pylint/test/unittest_checker_format.py @@ -20,6 +20,7 @@ from os import linesep import re import sys +import astroid from astroid import test_utils from pylint.checkers.format import * @@ -117,7 +118,7 @@ class SuperfluousParenthesesTest(CheckerTestCase): code = """from __future__ import print_function print('Hello world!') """ - tree = test_utils.build_module(code) + tree = astroid.parse(code) with self.assertNoMessages(): self.checker.process_module(tree) self.checker.process_tokens(tokenize_str(code)) diff --git a/pylint/test/unittest_checker_python3.py b/pylint/test/unittest_checker_python3.py index 57a4459..1bdea1d 100644 --- a/pylint/test/unittest_checker_python3.py +++ b/pylint/test/unittest_checker_python3.py @@ -66,7 +66,7 @@ class Python3CheckerTest(testutils.CheckerTestCase): def as_iterable_in_for_loop_test(self, fxn): code = "for x in {}(): pass".format(fxn) - module = test_utils.build_module(code) + module = astroid.parse(code) with self.assertNoMessages(): self.walk(module) @@ -84,13 +84,13 @@ class Python3CheckerTest(testutils.CheckerTestCase): def as_iterable_in_genexp_test(self, fxn): code = "x = (x for x in {}())".format(fxn) - module = test_utils.build_module(code) + module = astroid.parse(code) with self.assertNoMessages(): self.walk(module) def as_iterable_in_listcomp_test(self, fxn): code = "x = [x for x in {}(None, [1])]".format(fxn) - module = test_utils.build_module(code) + module = astroid.parse(code) with self.assertNoMessages(): self.walk(module) @@ -118,7 +118,7 @@ class Python3CheckerTest(testutils.CheckerTestCase): self.checker.visit_callfunc(node) def as_argument_to_callable_constructor_test(self, fxn, callable_fn): - module = test_utils.build_module("x = {}({}())".format(callable_fn, fxn)) + module = astroid.parse("x = {}({}())".format(callable_fn, fxn)) with self.assertNoMessages(): self.walk(module) @@ -135,7 +135,7 @@ class Python3CheckerTest(testutils.CheckerTestCase): def as_argument_to_str_join_test(self, fxn): code = "x = ''.join({}())".format(fxn) - module = test_utils.build_module(code) + module = astroid.parse(code) with self.assertNoMessages(): self.walk(module) @@ -250,9 +250,9 @@ class Python3CheckerTest(testutils.CheckerTestCase): self.checker.visit_import(node) def test_absolute_import(self): - module_import = test_utils.build_module( + module_import = astroid.parse( 'from __future__ import absolute_import; import os') - module_from = test_utils.build_module( + module_from = astroid.parse( 'from __future__ import absolute_import; from os import path') with self.assertNoMessages(): for module in (module_import, module_from): @@ -275,7 +275,7 @@ class Python3CheckerTest(testutils.CheckerTestCase): self.checker.visit_binop(node) def test_division_with_future_statement(self): - module = test_utils.build_module('from __future__ import division; 3 / 2') + module = astroid.parse('from __future__ import division; 3 / 2') with self.assertNoMessages(): self.walk(module) @@ -358,7 +358,7 @@ class Python3CheckerTest(testutils.CheckerTestCase): self.checker.visit_class(node) def test_metaclass_global_assignment(self): - module = test_utils.build_module('__metaclass__ = type') + module = astroid.parse('__metaclass__ = type') with self.assertNoMessages(): self.walk(module) @@ -385,7 +385,7 @@ class Python3CheckerTest(testutils.CheckerTestCase): @python2_only def test_checker_disabled_by_default(self): - node = test_utils.build_module(textwrap.dedent(""" + node = astroid.parse(textwrap.dedent(""" abc = 1l raise Exception, "test" raise "test" diff --git a/pylint/test/unittest_checker_variables.py b/pylint/test/unittest_checker_variables.py index e3dd939..a176a90 100644 --- a/pylint/test/unittest_checker_variables.py +++ b/pylint/test/unittest_checker_variables.py @@ -3,7 +3,9 @@ import sys import os import unittest +import astroid from astroid import test_utils + from pylint.checkers import variables from pylint.testutils import CheckerTestCase, linter, set_config, Message @@ -13,7 +15,7 @@ class VariablesCheckerTC(CheckerTestCase): def test_bitbucket_issue_78(self): """ Issue 78 report a false positive for unused-module """ - module = test_utils.build_module(""" + module = astroid.parse(""" from sys import path path += ['stuff'] def func(): diff --git a/pylint/test/unittest_pyreverse_inspector.py b/pylint/test/unittest_pyreverse_inspector.py index 404fec1..c555d91 100644 --- a/pylint/test/unittest_pyreverse_inspector.py +++ b/pylint/test/unittest_pyreverse_inspector.py @@ -19,6 +19,7 @@ import os import unittest +import astroid from astroid import nodes from astroid import bases from astroid import manager @@ -95,7 +96,7 @@ class LinkerTest(unittest.TestCase): self.assertEqual([i.name for i in interfaces], ['IMachin']) def test_interfaces(self): - module = test_utils.build_module(''' + module = astroid.parse(''' class Interface(object): pass class MyIFace(Interface): pass class AnotherIFace(Interface): pass diff --git a/pylint/test/unittest_utils.py b/pylint/test/unittest_utils.py index d631dbb..193e452 100644 --- a/pylint/test/unittest_utils.py +++ b/pylint/test/unittest_utils.py @@ -13,7 +13,8 @@ # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. import unittest -from astroid import test_utils +import astroid + from pylint import utils from pylint import interfaces from pylint.checkers.utils import check_messages @@ -54,7 +55,7 @@ class PyLintASTWalkerTest(unittest.TestCase): walker = utils.PyLintASTWalker(linter) checker = self.Checker() walker.add_checker(checker) - walker.walk(test_utils.build_module("x = func()")) + walker.walk(astroid.parse("x = func()")) self.assertEqual(set(['module', 'assname']), checker.called) diff --git a/pylint/testutils.py b/pylint/testutils.py index c7d8e1d..adc4e0c 100644 --- a/pylint/testutils.py +++ b/pylint/testutils.py @@ -30,7 +30,7 @@ from glob import glob from os import linesep, getcwd, sep from os.path import abspath, basename, dirname, isdir, join, splitext -from astroid import test_utils +import astroid from pylint import checkers from pylint.utils import PyLintASTWalker @@ -408,6 +408,6 @@ def create_tempfile(content=None): def create_file_backed_module(code): """Create an astroid module for the given code, backed by a real file.""" with create_tempfile() as temp: - module = test_utils.build_module(code) + module = astroid.parse(code) module.file = temp yield module |