summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorPierre Sassoulas <pierre.sassoulas@gmail.com>2021-08-31 22:15:29 +0200
committerPierre Sassoulas <pierre.sassoulas@gmail.com>2021-09-01 08:27:04 +0200
commit5f96098d658fd9c1b59c5f1675033485e1b3bad0 (patch)
treecfb6d8f4d46f7aa05c73b6cc10cabde3c7eae5de /tests
parentca9eddc137936d1ffe83ec78d051f1b23f7c27b1 (diff)
downloadpylint-git-5f96098d658fd9c1b59c5f1675033485e1b3bad0.tar.gz
Remove the python3 porting mode from the codebase
It's possible to use the python3 porting checker from an older pylint version. But it's not evolving anymore and was costing resource to maintain.
Diffstat (limited to 'tests')
-rw-r--r--tests/checkers/unittest_python3.py1178
-rw-r--r--tests/functional/a/abstract/abstract_abc_methods.py2
-rw-r--r--tests/functional/a/access/access_attr_before_def_false_positive.py2
-rw-r--r--tests/functional/a/access/access_to__name__.py2
-rw-r--r--tests/functional/a/access/access_to_protected_members.py2
-rw-r--r--tests/functional/a/arguments.py2
-rw-r--r--tests/functional/a/assign/assigning_non_slot.py2
-rw-r--r--tests/functional/b/bad_reversed_sequence.py2
-rw-r--r--tests/functional/b/base_init_vars.py4
-rw-r--r--tests/functional/c/cellvar_escaping_loop.py2
-rw-r--r--tests/functional/c/confidence_filter.rc2
-rw-r--r--tests/functional/d/defined_and_used_on_same_line.py2
-rw-r--r--tests/functional/d/dotted_ancestor.py3
-rw-r--r--tests/functional/d/dotted_ancestor.txt2
-rw-r--r--tests/functional/g/generated_members.rc2
-rw-r--r--tests/functional/i/import_error.py2
-rw-r--r--tests/functional/i/import_itself.py2
-rw-r--r--tests/functional/i/inherit_non_class.py2
-rw-r--r--tests/functional/i/invalid/e/invalid_exceptions_caught.py2
-rw-r--r--tests/functional/i/invalid/invalid_name.py2
-rw-r--r--tests/functional/l/len_checks.py2
-rw-r--r--tests/functional/l/logging_format_interpolation.py2
-rw-r--r--tests/functional/m/member/member_checks.py2
-rw-r--r--tests/functional/m/metaclass_attr_access.py5
-rw-r--r--tests/functional/m/method_hidden.py2
-rw-r--r--tests/functional/n/name/name_styles.py2
-rw-r--r--tests/functional/n/name/names_in__all__.py2
-rw-r--r--tests/functional/n/new_style_class_py_30.py2
-rw-r--r--tests/functional/n/no/no_name_in_module.py2
-rw-r--r--tests/functional/n/non/non_init_parent_called.py2
-rw-r--r--tests/functional/n/nonlocal_without_binding.py2
-rw-r--r--tests/functional/s/slots_checks.py2
-rw-r--r--tests/functional/s/string/string_formatting.py2
-rw-r--r--tests/functional/s/string/string_formatting_error.py2
-rw-r--r--tests/functional/s/string/string_log_formatting.py10
-rw-r--r--tests/functional/s/super/super_checks.py2
-rw-r--r--tests/functional/u/unpacking_non_sequence.py2
-rw-r--r--tests/functional/u/unused/unused_argument.py2
-rw-r--r--tests/functional/u/unused/unused_import.py2
-rw-r--r--tests/functional/u/unused/unused_name_from_wilcard_import.py2
-rw-r--r--tests/functional/w/wildcard_import.py2
-rw-r--r--tests/input/func_3k_removed_stuff_py_30.py2
-rw-r--r--tests/input/func_w0332_py_30.py4
-rw-r--r--tests/input/func_w0401.py2
-rw-r--r--tests/input/func_w0401_disabled.py2
-rw-r--r--tests/input/func_w0401_disabled_in_func.py2
-rw-r--r--tests/input/func_w0401_package/all_the_things.py2
-rw-r--r--tests/input/func_w0401_package/thing2.py2
-rw-r--r--tests/input/no_absolute_import.py5
-rw-r--r--tests/input/w0401_cycle.py2
-rw-r--r--tests/lint/unittest_lint.py13
-rw-r--r--tests/regrtest_data/func_block_disable_msg.py2
-rw-r--r--tests/regrtest_data/py3k-disabled.rc2
-rw-r--r--tests/regrtest_data/py3k_error_flag.py11
-rw-r--r--tests/regrtest_data/py3k_errors_and_warnings.py19
-rw-r--r--tests/test_self.py23
56 files changed, 57 insertions, 1308 deletions
diff --git a/tests/checkers/unittest_python3.py b/tests/checkers/unittest_python3.py
deleted file mode 100644
index 6dd78cd25..000000000
--- a/tests/checkers/unittest_python3.py
+++ /dev/null
@@ -1,1178 +0,0 @@
-# Copyright (c) 2014-2020 Claudiu Popa <pcmanticore@gmail.com>
-# Copyright (c) 2014-2015 Brett Cannon <brett@python.org>
-# Copyright (c) 2015 Ionel Cristian Maries <contact@ionelmc.ro>
-# Copyright (c) 2015 Cosmin Poieana <cmin@ropython.org>
-# Copyright (c) 2015 Viorel Stirbu <viorels@gmail.com>
-# Copyright (c) 2016-2017 Roy Williams <roy.williams.iii@gmail.com>
-# Copyright (c) 2016 Roy Williams <rwilliams@lyft.com>
-# Copyright (c) 2016 Derek Gustafson <degustaf@gmail.com>
-# Copyright (c) 2017 Daniel Miller <millerdev@gmail.com>
-# Copyright (c) 2018-2020 Anthony Sottile <asottile@umich.edu>
-# Copyright (c) 2018 sbagan <pnlbagan@gmail.com>
-# Copyright (c) 2018 Aivar Annamaa <aivarannamaa@users.noreply.github.com>
-# Copyright (c) 2018 Ville Skyttä <ville.skytta@iki.fi>
-# Copyright (c) 2019-2021 Pierre Sassoulas <pierre.sassoulas@gmail.com>
-# Copyright (c) 2019 Gabriel R Sezefredo <gabriel@sezefredo.com.br>
-# Copyright (c) 2019 Hugo van Kemenade <hugovk@users.noreply.github.com>
-# Copyright (c) 2019 Ashley Whetter <ashley@awhetter.co.uk>
-# Copyright (c) 2020 hippo91 <guillaume.peillex@gmail.com>
-# Copyright (c) 2020 Federico Bond <federicobond@gmail.com>
-# Copyright (c) 2020 Athos Ribeiro <athoscr@fedoraproject.org>
-# Copyright (c) 2021 Marc Mueller <30130371+cdce8p@users.noreply.github.com>
-# Copyright (c) 2021 Tiago Honorato <tiagohonorato1@gmail.com>
-# Copyright (c) 2021 tiagohonorato <61059243+tiagohonorato@users.noreply.github.com>
-# Copyright (c) 2021 David Gilman <davidgilman1@gmail.com>
-
-# Licensed under the GPL: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
-# For details: https://github.com/PyCQA/pylint/blob/main/LICENSE
-
-"""Tests for the python3 checkers."""
-
-# pylint: disable=too-many-public-methods,redefined-outer-name
-
-import astroid
-
-from pylint import testutils
-from pylint.checkers import python3 as checker
-from pylint.interfaces import INFERENCE, INFERENCE_FAILURE
-
-# TODO(cpopa): Port these to the functional test framework instead. pylint: disable=fixme
-
-
-class TestPython3Checker(testutils.CheckerTestCase):
-
- CHECKER_CLASS = checker.Python3Checker
-
- def check_bad_builtin(self, builtin_name):
- node = astroid.extract_node(builtin_name + " #@")
- message = builtin_name.lower() + "-builtin"
- with self.assertAddsMessages(testutils.Message(message, node=node)):
- self.checker.visit_name(node)
-
- def test_bad_builtins(self):
- builtins = [
- "apply",
- "buffer",
- "cmp",
- "coerce",
- "execfile",
- "file",
- "input",
- "intern",
- "long",
- "raw_input",
- "round",
- "reduce",
- "StandardError",
- "unichr",
- "unicode",
- "xrange",
- "reload",
- ]
- for builtin in builtins:
- self.check_bad_builtin(builtin)
-
- def as_iterable_in_for_loop_test(self, fxn):
- code = f"for x in {fxn}(): pass"
- module = astroid.parse(code)
- with self.assertNoMessages():
- self.walk(module)
-
- def as_used_by_iterable_in_for_loop_test(self, fxn):
- checker = f"{fxn}-builtin-not-iterating"
- node = astroid.extract_node(
- f"""
- for x in (whatever(
- {fxn}() #@
- )):
- pass
- """
- )
- message = testutils.Message(checker, node=node)
- with self.assertAddsMessages(message):
- self.checker.visit_call(node)
-
- def as_iterable_in_genexp_test(self, fxn):
- code = f"x = (x for x in {fxn}())"
- module = astroid.parse(code)
- with self.assertNoMessages():
- self.walk(module)
-
- def as_iterable_in_starred_context(self, fxn):
- code = f"x = test(*{fxn}())"
- module = astroid.parse(code)
- with self.assertNoMessages():
- self.walk(module)
-
- def as_iterable_in_listcomp_test(self, fxn):
- code = f"x = [x for x in {fxn}(None, [1])]"
- module = astroid.parse(code)
- with self.assertNoMessages():
- self.walk(module)
-
- def as_iterable_in_yield_from(self, fxn):
- code = f"yield from {fxn}()"
- module = astroid.parse(code)
- with self.assertNoMessages():
- self.walk(module)
-
- def as_used_in_variant_in_genexp_test(self, fxn):
- checker = f"{fxn}-builtin-not-iterating"
- node = astroid.extract_node(
- f"""
- list(
- __({fxn}(x))
- for x in [1]
- )
- """
- )
- message = testutils.Message(checker, node=node)
- with self.assertAddsMessages(message):
- self.checker.visit_call(node)
-
- def as_used_in_variant_in_listcomp_test(self, fxn):
- checker = f"{fxn}-builtin-not-iterating"
- node = astroid.extract_node(
- f"""
- [
- __({fxn}(None, x))
- for x in [[1]]]
- """
- )
- message = testutils.Message(checker, node=node)
- with self.assertAddsMessages(message):
- self.checker.visit_call(node)
-
- def as_argument_to_callable_constructor_test(self, fxn, callable_fn):
- module = astroid.parse(f"x = {callable_fn}({fxn}())")
- with self.assertNoMessages():
- self.walk(module)
-
- def as_argument_to_materialized_filter(self, callable_fn):
- module = astroid.parse(f"list(filter(None, {callable_fn}()))")
- with self.assertNoMessages():
- self.walk(module)
-
- def as_argument_to_random_fxn_test(self, fxn):
- checker = f"{fxn}-builtin-not-iterating"
- node = astroid.extract_node(
- f"""
- y(
- {fxn}() #@
- )
- """
- )
- message = testutils.Message(checker, node=node)
- with self.assertAddsMessages(message):
- self.checker.visit_call(node)
-
- def as_argument_to_str_join_test(self, fxn):
- code = f"x = ''.join({fxn}())"
- module = astroid.parse(code)
- with self.assertNoMessages():
- self.walk(module)
-
- def as_argument_to_itertools_functions(self, fxn):
- code = f"""
- from __future__ import absolute_import
- import itertools
- from itertools import product
- for i,j in product({fxn}(), repeat=2):
- pass
- for i,j in itertools.product({fxn}(), repeat=2):
- pass
- """
- module = astroid.parse(code)
- with self.assertNoMessages():
- self.walk(module)
-
- def as_argument_to_zip_test(self, fxn):
- module = astroid.parse(f"list(zip({fxn}))")
- with self.assertNoMessages():
- self.walk(module)
-
- def as_argument_to_map_test(self, fxn):
- module = astroid.parse(f"list(map(__, {fxn}()))")
- with self.assertNoMessages():
- self.walk(module)
-
- def as_iterable_in_unpacking(self, fxn):
- node = astroid.extract_node(
- f"""
- a, b = __({fxn}())
- """
- )
- with self.assertNoMessages():
- self.checker.visit_call(node)
-
- def as_assignment(self, fxn):
- checker = f"{fxn}-builtin-not-iterating"
- node = astroid.extract_node(
- f"""
- a = __({fxn}())
- """
- )
- message = testutils.Message(checker, node=node)
- with self.assertAddsMessages(message):
- self.checker.visit_call(node)
-
- def iterating_context_tests(self, fxn):
- """Helper for verifying a function isn't used as an iterator."""
- self.as_iterable_in_for_loop_test(fxn)
- self.as_used_by_iterable_in_for_loop_test(fxn)
- self.as_iterable_in_genexp_test(fxn)
- self.as_iterable_in_listcomp_test(fxn)
- self.as_used_in_variant_in_genexp_test(fxn)
- self.as_used_in_variant_in_listcomp_test(fxn)
- self.as_argument_to_random_fxn_test(fxn)
- self.as_argument_to_str_join_test(fxn)
- self.as_iterable_in_unpacking(fxn)
- self.as_assignment(fxn)
- self.as_argument_to_materialized_filter(fxn)
- self.as_iterable_in_yield_from(fxn)
- self.as_iterable_in_starred_context(fxn)
- self.as_argument_to_itertools_functions(fxn)
- self.as_argument_to_zip_test(fxn)
- self.as_argument_to_map_test(fxn)
- for func in (
- "iter",
- "list",
- "tuple",
- "sorted",
- "set",
- "sum",
- "any",
- "all",
- "enumerate",
- "dict",
- "OrderedDict",
- ):
- self.as_argument_to_callable_constructor_test(fxn, func)
-
- def test_dict_subclasses_methods_in_iterating_context(self):
- iterating, not_iterating = astroid.extract_node(
- """
- from __future__ import absolute_import
- from collections import defaultdict
- d = defaultdict(list)
- a, b = d.keys() #@
- x = d.keys() #@
- """
- )
-
- with self.assertNoMessages():
- self.checker.visit_call(iterating.value)
-
- message = testutils.Message("dict-keys-not-iterating", node=not_iterating.value)
- with self.assertAddsMessages(message):
- self.checker.visit_call(not_iterating.value)
-
- def test_dict_methods_in_iterating_context(self):
- iterating_code = [
- "for x in {}(): pass",
- "(x for x in {}())",
- "[x for x in {}()]",
- "iter({}())",
- "a, b = {}()",
- "max({}())",
- "min({}())",
- "3 in {}()",
- "3 not in {}()",
- "set().update({}())",
- "[].extend({}())",
- "{{}}.update({}())",
- """
- from __future__ import absolute_import
- from itertools import chain
- chain.from_iterable({}())
- """,
- ]
- non_iterating_code = ["x = __({}())", "__({}())[0]"]
-
- for method in ("keys", "items", "values"):
- dict_method = f"{{}}.{method}"
-
- for code in iterating_code:
- with_value = code.format(dict_method)
- module = astroid.parse(with_value)
- with self.assertNoMessages():
- self.walk(module)
-
- for code in non_iterating_code:
- with_value = code.format(dict_method)
- node = astroid.extract_node(with_value)
-
- checker = f"dict-{method}-not-iterating"
- message = testutils.Message(checker, node=node)
- with self.assertAddsMessages(message):
- self.checker.visit_call(node)
-
- def test_map_in_iterating_context(self):
- self.iterating_context_tests("map")
-
- def test_zip_in_iterating_context(self):
- self.iterating_context_tests("zip")
-
- def test_range_in_iterating_context(self):
- self.iterating_context_tests("range")
-
- def test_filter_in_iterating_context(self):
- self.iterating_context_tests("filter")
-
- def defined_method_test(self, method, warning):
- """Helper for verifying that a certain method is not defined."""
- node = astroid.extract_node(
- f"""
- class Foo(object):
- def __{method}__(self, other): #@
- pass"""
- )
- message = testutils.Message(warning, node=node)
- with self.assertAddsMessages(message):
- self.checker.visit_functiondef(node)
-
- def test_delslice_method(self):
- self.defined_method_test("delslice", "delslice-method")
-
- def test_getslice_method(self):
- self.defined_method_test("getslice", "getslice-method")
-
- def test_setslice_method(self):
- self.defined_method_test("setslice", "setslice-method")
-
- def test_coerce_method(self):
- self.defined_method_test("coerce", "coerce-method")
-
- def test_oct_method(self):
- self.defined_method_test("oct", "oct-method")
-
- def test_hex_method(self):
- self.defined_method_test("hex", "hex-method")
-
- def test_nonzero_method(self):
- self.defined_method_test("nonzero", "nonzero-method")
-
- def test_cmp_method(self):
- self.defined_method_test("cmp", "cmp-method")
-
- def test_div_method(self):
- self.defined_method_test("div", "div-method")
-
- def test_idiv_method(self):
- self.defined_method_test("idiv", "idiv-method")
-
- def test_rdiv_method(self):
- self.defined_method_test("rdiv", "rdiv-method")
-
- def test_eq_and_hash_method(self):
- """Helper for verifying that a certain method is not defined."""
- node = astroid.extract_node(
- """
- class Foo(object): #@
- def __eq__(self, other):
- pass
- def __hash__(self):
- pass"""
- )
- with self.assertNoMessages():
- self.checker.visit_classdef(node)
-
- def test_eq_and_hash_is_none(self):
- """Helper for verifying that a certain method is not defined."""
- node = astroid.extract_node(
- """
- class Foo(object): #@
- def __eq__(self, other):
- pass
- __hash__ = None"""
- )
- with self.assertNoMessages():
- self.checker.visit_classdef(node)
-
- def test_eq_without_hash_method(self):
- """Helper for verifying that a certain method is not defined."""
- node = astroid.extract_node(
- """
- class Foo(object): #@
- def __eq__(self, other):
- pass"""
- )
- message = testutils.Message("eq-without-hash", node=node)
- with self.assertAddsMessages(message):
- self.checker.visit_classdef(node)
-
- def test_relative_import(self):
- node = astroid.extract_node("import string #@")
- message = testutils.Message("no-absolute-import", node=node)
- with self.assertAddsMessages(message):
- self.checker.visit_import(node)
- with self.assertNoMessages():
- # message should only be added once
- self.checker.visit_import(node)
-
- def test_relative_from_import(self):
- node = astroid.extract_node("from os import path #@")
- message = testutils.Message("no-absolute-import", node=node)
- with self.assertAddsMessages(message):
- self.checker.visit_importfrom(node)
- with self.assertNoMessages():
- # message should only be added once
- self.checker.visit_importfrom(node)
-
- def test_absolute_import(self):
- module_import = astroid.parse(
- "from __future__ import absolute_import; import os"
- )
- module_from = astroid.parse(
- "from __future__ import absolute_import; from os import path"
- )
- with self.assertNoMessages():
- for module in (module_import, module_from):
- self.walk(module)
-
- def test_import_star_module_level(self):
- node = astroid.extract_node(
- """
- def test():
- from lala import * #@
- """
- )
- absolute = testutils.Message("no-absolute-import", node=node)
- star = testutils.Message("import-star-module-level", node=node)
- with self.assertAddsMessages(absolute, star):
- self.checker.visit_importfrom(node)
-
- def test_division(self):
- nodes = astroid.extract_node(
- """\
- from _unknown import a, b
- 3 / 2 #@
- 3 / int(a) #@
- int(a) / 3 #@
- a / b #@
- """
- )
- for node in nodes:
- message = testutils.Message("old-division", node=node)
- with self.assertAddsMessages(message):
- self.checker.visit_binop(node)
-
- def test_division_with_future_statement(self):
- module = astroid.parse("from __future__ import division; 3 / 2")
- with self.assertNoMessages():
- self.walk(module)
-
- def test_floor_division(self):
- node = astroid.extract_node(" 3 // 2 #@")
- with self.assertNoMessages():
- self.checker.visit_binop(node)
-
- def test_division_by_float(self):
- nodes = astroid.extract_node(
- """\
- 3.0 / 2 #@
- 3 / 2.0 #@
- 3 / float(a) #@
- float(a) / 3 #@
- """
- )
- with self.assertNoMessages():
- for node in nodes:
- self.checker.visit_binop(node)
-
- def test_division_different_types(self):
- nodes = astroid.extract_node(
- """
- class A:
- pass
- A / 2 #@
- A() / 2 #@
- "a" / "a" #@
- class Path:
- def __div__(self, other):
- return 42
- Path() / 24 #@
- """
- )
- for node in nodes:
- with self.assertNoMessages():
- self.checker.visit_binop(node)
-
- def test_dict_iter_method(self):
- for meth in ("keys", "values", "items"):
- node = astroid.extract_node(f"x.iter{meth}() #@")
- message = testutils.Message("dict-iter-method", node=node)
- with self.assertAddsMessages(message):
- self.checker.visit_call(node)
-
- def test_dict_iter_method_on_dict(self):
- nodes = astroid.extract_node(
- """
- from collections import defaultdict
- {}.iterkeys() #@
- defaultdict(list).iterkeys() #@
- class Someclass(dict):
- pass
- Someclass().iterkeys() #@
-
- # Emits even though we are not sure they are dicts
- x.iterkeys() #@
-
- def func(x):
- x.iterkeys() #@
- """
- )
- for node in nodes:
- message = testutils.Message("dict-iter-method", node=node)
- with self.assertAddsMessages(message):
- self.checker.visit_call(node)
-
- def test_dict_not_iter_method(self):
- arg_node = astroid.extract_node("x.iterkeys(x) #@")
- stararg_node = astroid.extract_node("x.iterkeys(*x) #@")
- kwarg_node = astroid.extract_node("x.iterkeys(y=x) #@")
- with self.assertNoMessages():
- for node in (arg_node, stararg_node, kwarg_node):
- self.checker.visit_call(node)
-
- def test_dict_view_method(self):
- for meth in ("keys", "values", "items"):
- node = astroid.extract_node(f"x.view{meth}() #@")
- message = testutils.Message("dict-view-method", node=node)
- with self.assertAddsMessages(message):
- self.checker.visit_call(node)
-
- def test_dict_viewkeys(self):
- nodes = astroid.extract_node(
- """
- from collections import defaultdict
- {}.viewkeys() #@
- defaultdict(list).viewkeys() #@
- class Someclass(dict):
- pass
- Someclass().viewkeys() #@
-
- # Emits even though they might not be dicts
- x.viewkeys() #@
-
- def func(x):
- x.viewkeys() #@
- """
- )
- for node in nodes:
- message = testutils.Message("dict-view-method", node=node)
- with self.assertAddsMessages(message):
- self.checker.visit_call(node)
-
- def test_next_method(self):
- node = astroid.extract_node("x.next() #@")
- message = testutils.Message("next-method-called", node=node)
- with self.assertAddsMessages(message):
- self.checker.visit_call(node)
-
- def test_not_next_method(self):
- arg_node = astroid.extract_node("x.next(x) #@")
- stararg_node = astroid.extract_node("x.next(*x) #@")
- kwarg_node = astroid.extract_node("x.next(y=x) #@")
- with self.assertNoMessages():
- for node in (arg_node, stararg_node, kwarg_node):
- self.checker.visit_call(node)
-
- def test_metaclass_assignment(self):
- node = astroid.extract_node(
- """
- class Foo(object): #@
- __metaclass__ = type"""
- )
- message = testutils.Message("metaclass-assignment", node=node)
- with self.assertAddsMessages(message):
- self.checker.visit_classdef(node)
-
- def test_metaclass_global_assignment(self):
- module = astroid.parse("__metaclass__ = type")
- with self.assertNoMessages():
- self.walk(module)
-
- def test_xreadlines_attribute(self):
- node = astroid.extract_node(
- """
- f.xreadlines #@
- """
- )
- message = testutils.Message("xreadlines-attribute", node=node)
- with self.assertAddsMessages(message):
- self.checker.visit_attribute(node)
-
- def test_exception_message_attribute(self):
- node = astroid.extract_node(
- """
- try:
- raise Exception("test")
- except Exception as e:
- e.message #@
- """
- )
- message = testutils.Message("exception-message-attribute", node=node)
- with self.assertAddsMessages(message):
- self.checker.visit_attribute(node)
-
- def test_normal_message_attribute(self):
- node = astroid.extract_node(
- """
- e.message #@
- """
- )
- with self.assertNoMessages():
- self.checker.visit_attribute(node)
-
- def test_invalid_codec(self):
- node = astroid.extract_node('foobar.encode("hex") #@')
- message = testutils.Message("invalid-str-codec", node=node)
- with self.assertAddsMessages(message):
- self.checker.visit_call(node)
-
- def test_valid_codec(self):
- node = astroid.extract_node('foobar.encode("ascii", "ignore") #@')
- with self.assertNoMessages():
- self.checker.visit_call(node)
-
- def test_visit_call_with_kwarg(self):
- node = astroid.extract_node('foobar.raz(encoding="hex") #@')
- with self.assertNoMessages():
- self.checker.visit_call(node)
-
- def test_invalid_open_codec(self):
- node = astroid.extract_node('open(foobar, encoding="hex") #@')
- message = testutils.Message("invalid-str-codec", node=node)
- with self.assertAddsMessages(message):
- self.checker.visit_call(node)
-
- def test_valid_open_codec(self):
- node = astroid.extract_node('open(foobar, encoding="palmos") #@')
- with self.assertNoMessages():
- self.checker.visit_call(node)
-
- def test_using_cmp_argument(self):
- nodes = astroid.extract_node(
- """
- [].sort(cmp=lambda x: x) #@
- a = list(range(x))
- a.sort(cmp=lambda x: x) #@
-
- sorted([], cmp=lambda x: x) #@
- """
- )
- for node in nodes:
- message = testutils.Message("using-cmp-argument", node=node)
- with self.assertAddsMessages(message):
- self.checker.visit_call(node)
-
- def test_sys_maxint(self):
- node = astroid.extract_node(
- """
- import sys
- sys.maxint #@
- """
- )
- message = testutils.Message("sys-max-int", node=node)
- with self.assertAddsMessages(message):
- self.checker.visit_attribute(node)
-
- def test_itertools_izip(self):
- node = astroid.extract_node(
- """
- from itertools import izip #@
- """
- )
- absolute_import_message = testutils.Message("no-absolute-import", node=node)
- message = testutils.Message("deprecated-itertools-function", node=node)
- with self.assertAddsMessages(absolute_import_message, message):
- self.checker.visit_importfrom(node)
-
- def test_deprecated_types_fields(self):
- node = astroid.extract_node(
- """
- from types import StringType #@
- """
- )
- absolute_import_message = testutils.Message("no-absolute-import", node=node)
- message = testutils.Message("deprecated-types-field", node=node)
- with self.assertAddsMessages(absolute_import_message, message):
- self.checker.visit_importfrom(node)
-
- def test_sys_maxint_imort_from(self):
- node = astroid.extract_node(
- """
- from sys import maxint #@
- """
- )
- absolute_import_message = testutils.Message("no-absolute-import", node=node)
- message = testutils.Message("sys-max-int", node=node)
- with self.assertAddsMessages(absolute_import_message, message):
- self.checker.visit_importfrom(node)
-
- def test_object_maxint(self):
- node = astroid.extract_node(
- """
- sys = object()
- sys.maxint #@
- """
- )
- with self.assertNoMessages():
- self.checker.visit_attribute(node)
-
- def test_bad_import(self):
- node = astroid.extract_node(
- """
- import urllib2, sys #@
- """
- )
- absolute_import_message = testutils.Message("no-absolute-import", node=node)
- message = testutils.Message("bad-python3-import", node=node)
- with self.assertAddsMessages(absolute_import_message, message):
- self.checker.visit_import(node)
-
- def test_bad_import_turtle(self):
- node = astroid.extract_node(
- """
- import turtle #@
- turtle.Turtle()
- """
- )
- absolute_import_message = testutils.Message("no-absolute-import", node=node)
- with self.assertAddsMessages(absolute_import_message):
- self.checker.visit_import(node)
-
- def test_bad_import_dbm(self):
- node = astroid.extract_node(
- """
- from dbm import open as open_ #@
- open_("dummy.db")
- """
- )
- absolute_import_message = testutils.Message("no-absolute-import", node=node)
- with self.assertAddsMessages(absolute_import_message):
- self.checker.visit_importfrom(node)
-
- def test_bad_import_conditional(self):
- node = astroid.extract_node(
- """
- import six
- if six.PY2:
- import urllib2 #@
- """
- )
- absolute_import_message = testutils.Message("no-absolute-import", node=node)
- with self.assertAddsMessages(absolute_import_message):
- self.checker.visit_import(node)
-
- def test_bad_import_try_except_handler(self):
- node = astroid.extract_node(
- """
- try:
- from hashlib import sha
- except:
- import sha #@
- """
- )
- absolute_import_message = testutils.Message("no-absolute-import", node=node)
- with self.assertAddsMessages(absolute_import_message):
- self.checker.visit_import(node)
-
- def test_bad_import_try(self):
- node = astroid.extract_node(
- """
- try:
- import md5 #@
- except:
- from hashlib import md5
- finally:
- pass
- """
- )
- absolute_import_message = testutils.Message("no-absolute-import", node=node)
- with self.assertAddsMessages(absolute_import_message):
- self.checker.visit_import(node)
-
- def test_bad_import_try_finally(self):
- node = astroid.extract_node(
- """
- try:
- import Queue #@
- finally:
- import queue
- """
- )
- absolute_import_message = testutils.Message("no-absolute-import", node=node)
- message = testutils.Message("bad-python3-import", node=node)
- with self.assertAddsMessages(absolute_import_message, message):
- self.checker.visit_import(node)
-
- def test_bad_import_from(self):
- node = astroid.extract_node(
- """
- from cStringIO import StringIO #@
- """
- )
- absolute_import_message = testutils.Message("no-absolute-import", node=node)
- message = testutils.Message("bad-python3-import", node=node)
- with self.assertAddsMessages(absolute_import_message, message):
- self.checker.visit_importfrom(node)
-
- def test_bad_string_attribute(self):
- node = astroid.extract_node(
- """
- import string
- string.maketrans #@
- """
- )
- message = testutils.Message("deprecated-string-function", node=node)
- with self.assertAddsMessages(message):
- self.checker.visit_attribute(node)
-
- def test_bad_operator_attribute(self):
- node = astroid.extract_node(
- """
- import operator
- operator.div #@
- """
- )
- message = testutils.Message("deprecated-operator-function", node=node)
- with self.assertAddsMessages(message):
- self.checker.visit_attribute(node)
-
- def test_comprehension_escape(self):
- assign, escaped_node = astroid.extract_node(
- """
- a = [i for i in range(10)] #@
- i #@
- """
- )
- good_module = astroid.parse(
- """
- {c for c in range(10)} #@
- {j:j for j in range(10)} #@
- [image_child] = [x for x in range(10)]
- thumbnail = func(__(image_child))
- """
- )
- message = testutils.Message("comprehension-escape", node=escaped_node)
- with self.assertAddsMessages(message):
- self.checker.visit_listcomp(assign.value)
-
- with self.assertNoMessages():
- self.walk(good_module)
-
- def test_comprehension_escape_newly_introduced(self):
- node = astroid.extract_node(
- """
- [i for i in range(3)]
- for i in range(3):
- i
- """
- )
- with self.assertNoMessages():
- self.walk(node)
-
- def test_exception_escape(self):
- module = astroid.parse(
- """
- try: 1/0
- except ValueError as exc:
- pass
- exc #@
- try:
- 2/0
- except (ValueError, TypeError) as exc:
- exc = 2
- exc #@
- try:
- 2/0
- except (ValueError, TypeError): #@
- exc = 2
- exc #@
- try:
- 1/0
- except (ValueError, TypeError) as exc:
- foo(bar for bar in exc.bar)
- """
- )
- message = testutils.Message("exception-escape", node=module.body[1].value)
- with self.assertAddsMessages(message):
- self.checker.visit_excepthandler(module.body[0].handlers[0])
- with self.assertNoMessages():
- self.checker.visit_excepthandler(module.body[2].handlers[0])
- self.checker.visit_excepthandler(module.body[4].handlers[0])
- self.checker.visit_excepthandler(module.body[6].handlers[0])
-
- def test_bad_sys_attribute(self):
- node = astroid.extract_node(
- """
- import sys
- sys.exc_clear #@
- """
- )
- message = testutils.Message("deprecated-sys-function", node=node)
- with self.assertAddsMessages(message):
- self.checker.visit_attribute(node)
-
- def test_bad_urllib_attribute(self):
- nodes = astroid.extract_node(
- """
- import urllib
- urllib.addbase #@
- urllib.splithost #@
- urllib.urlretrieve #@
- urllib.urlopen #@
- urllib.urlencode #@
- """
- )
- for node in nodes:
- message = testutils.Message("deprecated-urllib-function", node=node)
- with self.assertAddsMessages(message):
- self.checker.visit_attribute(node)
-
- def test_ok_string_attribute(self):
- node = astroid.extract_node(
- """
- import string
- string.ascii_letters #@
- """
- )
- with self.assertNoMessages():
- self.checker.visit_attribute(node)
-
- def test_bad_string_call(self):
- node = astroid.extract_node(
- """
- import string
- string.upper("hello world") #@
- """
- )
- message = testutils.Message("deprecated-string-function", node=node)
- with self.assertAddsMessages(message):
- self.checker.visit_call(node)
-
- def test_ok_shadowed_call(self):
- node = astroid.extract_node(
- """
- import six.moves.configparser
- six.moves.configparser.ConfigParser() #@
- """
- )
- with self.assertNoMessages():
- self.checker.visit_call(node)
-
- def test_ok_string_call(self):
- node = astroid.extract_node(
- """
- import string
- string.Foramtter() #@
- """
- )
- with self.assertNoMessages():
- self.checker.visit_call(node)
-
- def test_bad_string_import_from(self):
- node = astroid.extract_node(
- """
- from string import atoi #@
- """
- )
- absolute_import_message = testutils.Message("no-absolute-import", node=node)
- message = testutils.Message("deprecated-string-function", node=node)
- with self.assertAddsMessages(absolute_import_message, message):
- self.checker.visit_importfrom(node)
-
- def test_ok_string_import_from(self):
- node = astroid.extract_node(
- """
- from string import digits #@
- """
- )
- absolute_import_message = testutils.Message("no-absolute-import", node=node)
- with self.assertAddsMessages(absolute_import_message):
- self.checker.visit_importfrom(node)
-
- def test_bad_str_translate_call_string_literal(self):
- node = astroid.extract_node(
- """
- foobar.translate(None, 'abc123') #@
- """
- )
- message = testutils.Message(
- "deprecated-str-translate-call", node=node, confidence=INFERENCE_FAILURE
- )
- with self.assertAddsMessages(message):
- self.checker.visit_call(node)
-
- def test_bad_str_translate_call_variable(self):
- node = astroid.extract_node(
- """
- def raz(foobar):
- foobar.translate(None, 'hello') #@
- """
- )
- message = testutils.Message(
- "deprecated-str-translate-call", node=node, confidence=INFERENCE_FAILURE
- )
- with self.assertAddsMessages(message):
- self.checker.visit_call(node)
-
- def test_bad_str_translate_call_infer_str(self):
- node = astroid.extract_node(
- """
- foobar = "hello world"
- foobar.translate(None, foobar) #@
- """
- )
- message = testutils.Message(
- "deprecated-str-translate-call", node=node, confidence=INFERENCE
- )
- with self.assertAddsMessages(message):
- self.checker.visit_call(node)
-
- def test_ok_str_translate_call_integer(self):
- node = astroid.extract_node(
- """
- foobar.translate(None, 33) #@
- """
- )
- with self.assertNoMessages():
- self.checker.visit_call(node)
-
- def test_ok_str_translate_call_keyword(self):
- node = astroid.extract_node(
- """
- foobar.translate(None, 'foobar', raz=33) #@
- """
- )
- with self.assertNoMessages():
- self.checker.visit_call(node)
-
- def test_ok_str_translate_call_not_str(self):
- node = astroid.extract_node(
- """
- foobar = {}
- foobar.translate(None, 'foobar') #@
- """
- )
- with self.assertNoMessages():
- self.checker.visit_call(node)
-
- def test_non_py2_conditional(self):
- code = """
- from __future__ import absolute_import
- import sys
- x = {}
- if sys.maxsize:
- x.iterkeys() #@
- """
- node = astroid.extract_node(code)
- module = node.parent.parent
- message = testutils.Message("dict-iter-method", node=node)
- with self.assertAddsMessages(message):
- self.walk(module)
-
- def test_six_conditional(self):
- code = """
- from __future__ import absolute_import
- import six
- x = {}
- if six.PY2:
- x.iterkeys()
- """
- module = astroid.parse(code)
- with self.assertNoMessages():
- self.walk(module)
-
- def test_versioninfo_conditional(self):
- code = """
- from __future__ import absolute_import
- import sys
- x = {}
- if sys.version_info[0] == 2:
- x.iterkeys()
- """
- module = astroid.parse(code)
- with self.assertNoMessages():
- self.walk(module)
-
- def test_versioninfo_tuple_conditional(self):
- code = """
- from __future__ import absolute_import
- import sys
- x = {}
- if sys.version_info == (2, 7):
- x.iterkeys()
- """
- module = astroid.parse(code)
- with self.assertNoMessages():
- self.walk(module)
-
- def test_six_ifexp_conditional(self):
- code = """
- from __future__ import absolute_import
- import six
- import string
- string.translate if six.PY2 else None
- """
- module = astroid.parse(code)
- with self.assertNoMessages():
- self.walk(module)
-
- def test_next_defined(self):
- node = astroid.extract_node(
- """
- class Foo(object):
- def next(self): #@
- pass"""
- )
- message = testutils.Message("next-method-defined", node=node)
- with self.assertAddsMessages(message):
- self.checker.visit_functiondef(node)
-
- def test_next_defined_too_many_args(self):
- node = astroid.extract_node(
- """
- class Foo(object):
- def next(self, foo=None): #@
- pass"""
- )
- with self.assertNoMessages():
- self.checker.visit_functiondef(node)
-
- def test_next_defined_static_method_too_many_args(self):
- node = astroid.extract_node(
- """
- class Foo(object):
- @staticmethod
- def next(self): #@
- pass"""
- )
- with self.assertNoMessages():
- self.checker.visit_functiondef(node)
-
- def test_next_defined_static_method(self):
- node = astroid.extract_node(
- """
- class Foo(object):
- @staticmethod
- def next(): #@
- pass"""
- )
- message = testutils.Message("next-method-defined", node=node)
- with self.assertAddsMessages(message):
- self.checker.visit_functiondef(node)
-
- def test_next_defined_class_method(self):
- node = astroid.extract_node(
- """
- class Foo(object):
- @classmethod
- def next(cls): #@
- pass"""
- )
- message = testutils.Message("next-method-defined", node=node)
- with self.assertAddsMessages(message):
- self.checker.visit_functiondef(node)
diff --git a/tests/functional/a/abstract/abstract_abc_methods.py b/tests/functional/a/abstract/abstract_abc_methods.py
index d174669a5..d63389c50 100644
--- a/tests/functional/a/abstract/abstract_abc_methods.py
+++ b/tests/functional/a/abstract/abstract_abc_methods.py
@@ -1,5 +1,5 @@
""" This should not warn about `prop` being abstract in Child """
-# pylint: disable=too-few-public-methods, no-absolute-import,metaclass-assignment, useless-object-inheritance
+# pylint: disable=too-few-public-methods, useless-object-inheritance
import abc
diff --git a/tests/functional/a/access/access_attr_before_def_false_positive.py b/tests/functional/a/access/access_attr_before_def_false_positive.py
index 00b7e40ed..fbad8c377 100644
--- a/tests/functional/a/access/access_attr_before_def_false_positive.py
+++ b/tests/functional/a/access/access_attr_before_def_false_positive.py
@@ -1,5 +1,5 @@
# pylint: disable=invalid-name,too-many-public-methods,attribute-defined-outside-init
-# pylint: disable=no-absolute-import, useless-object-inheritance,too-few-public-methods
+# pylint: disable= useless-object-inheritance,too-few-public-methods
"""This module demonstrates a possible problem of pyLint with calling __init__ s
from inherited classes.
Initializations done there are not considered, which results in Error E0203 for
diff --git a/tests/functional/a/access/access_to__name__.py b/tests/functional/a/access/access_to__name__.py
index 82dcdbe78..1a622824b 100644
--- a/tests/functional/a/access/access_to__name__.py
+++ b/tests/functional/a/access/access_to__name__.py
@@ -1,4 +1,4 @@
-# pylint: disable=too-few-public-methods, print-statement, useless-object-inheritance
+# pylint: disable=too-few-public-methods, useless-object-inheritance
"""test access to __name__ gives undefined member on new/old class instances
but not on new/old class object
"""
diff --git a/tests/functional/a/access/access_to_protected_members.py b/tests/functional/a/access/access_to_protected_members.py
index 06438400a..ffbfabf15 100644
--- a/tests/functional/a/access/access_to_protected_members.py
+++ b/tests/functional/a/access/access_to_protected_members.py
@@ -1,4 +1,4 @@
-# pylint: disable=too-few-public-methods, super-init-not-called, print-statement
+# pylint: disable=too-few-public-methods, super-init-not-called
# pylint: disable=no-classmethod-decorator,useless-object-inheritance
"""Test external access to protected class members."""
from __future__ import print_function
diff --git a/tests/functional/a/arguments.py b/tests/functional/a/arguments.py
index e1a8005aa..9e66ff18d 100644
--- a/tests/functional/a/arguments.py
+++ b/tests/functional/a/arguments.py
@@ -1,4 +1,4 @@
-# pylint: disable=too-few-public-methods, no-absolute-import,missing-docstring,import-error,wrong-import-position
+# pylint: disable=too-few-public-methods, missing-docstring,import-error,wrong-import-position
# pylint: disable=wrong-import-order, useless-object-inheritance,unnecessary-lambda, consider-using-f-string
def decorator(fun):
diff --git a/tests/functional/a/assign/assigning_non_slot.py b/tests/functional/a/assign/assigning_non_slot.py
index 4789014ff..cf673692f 100644
--- a/tests/functional/a/assign/assigning_non_slot.py
+++ b/tests/functional/a/assign/assigning_non_slot.py
@@ -1,7 +1,7 @@
""" Checks assigning attributes not found in class slots
will trigger assigning-non-slot warning.
"""
-# pylint: disable=too-few-public-methods, no-init, missing-docstring, no-absolute-import, import-error, useless-object-inheritance, redundant-u-string-prefix
+# pylint: disable=too-few-public-methods, no-init, missing-docstring, import-error, useless-object-inheritance, redundant-u-string-prefix
from collections import deque
from missing import Unknown
diff --git a/tests/functional/b/bad_reversed_sequence.py b/tests/functional/b/bad_reversed_sequence.py
index 0d7b84da0..101123330 100644
--- a/tests/functional/b/bad_reversed_sequence.py
+++ b/tests/functional/b/bad_reversed_sequence.py
@@ -1,6 +1,6 @@
""" Checks that reversed() receive proper argument """
# pylint: disable=missing-docstring, useless-object-inheritance
-# pylint: disable=too-few-public-methods,no-self-use,no-absolute-import
+# pylint: disable=too-few-public-methods,no-self-use
from collections import deque, OrderedDict
from enum import IntEnum
diff --git a/tests/functional/b/base_init_vars.py b/tests/functional/b/base_init_vars.py
index 08e2828ec..b77ec2b8d 100644
--- a/tests/functional/b/base_init_vars.py
+++ b/tests/functional/b/base_init_vars.py
@@ -1,7 +1,7 @@
-# pylint:disable=no-self-use, print-statement
+# pylint:disable=no-self-use
# pylint:disable=too-few-public-methods, useless-object-inheritance
"""Checks that class variables are seen as inherited !"""
-__revision__ = ''
+
class BaseClass(object):
"""A simple base class
diff --git a/tests/functional/c/cellvar_escaping_loop.py b/tests/functional/c/cellvar_escaping_loop.py
index d2c1fb4a5..5520fe949 100644
--- a/tests/functional/c/cellvar_escaping_loop.py
+++ b/tests/functional/c/cellvar_escaping_loop.py
@@ -1,4 +1,4 @@
-# pylint: disable=print-statement, unnecessary-comprehension,missing-docstring,too-few-public-methods
+# pylint: disable= unnecessary-comprehension,missing-docstring,too-few-public-methods
"""Tests for loopvar-in-closure."""
from __future__ import print_function
diff --git a/tests/functional/c/confidence_filter.rc b/tests/functional/c/confidence_filter.rc
index 74953b686..5d21cb56e 100644
--- a/tests/functional/c/confidence_filter.rc
+++ b/tests/functional/c/confidence_filter.rc
@@ -1,3 +1,3 @@
[Messages Control]
-disable=no-init,too-few-public-methods,undefined-variable,print-statement
+disable=no-init,too-few-public-methods,undefined-variable
confidence=INFERENCE,HIGH,UNDEFINED
diff --git a/tests/functional/d/defined_and_used_on_same_line.py b/tests/functional/d/defined_and_used_on_same_line.py
index d5bdb4db0..98e5077a6 100644
--- a/tests/functional/d/defined_and_used_on_same_line.py
+++ b/tests/functional/d/defined_and_used_on_same_line.py
@@ -1,5 +1,5 @@
"""Check for definitions and usage happening on the same line."""
-#pylint: disable=missing-docstring,multiple-statements,no-absolute-import,parameter-unpacking,wrong-import-position,unnecessary-comprehension,unspecified-encoding
+#pylint: disable=missing-docstring,multiple-statements,wrong-import-position,unnecessary-comprehension,unspecified-encoding
from __future__ import print_function
print([index
for index in range(10)])
diff --git a/tests/functional/d/dotted_ancestor.py b/tests/functional/d/dotted_ancestor.py
index 2c82d89a3..89826179a 100644
--- a/tests/functional/d/dotted_ancestor.py
+++ b/tests/functional/d/dotted_ancestor.py
@@ -1,9 +1,8 @@
"""bla"""
-# pylint: disable=no-absolute-import
+
from ..n.non import non_init_parent_called
-__revision__ = 'yo'
class Aaaa(non_init_parent_called.AAAA): # [too-few-public-methods]
"""test dotted name in ancestors"""
diff --git a/tests/functional/d/dotted_ancestor.txt b/tests/functional/d/dotted_ancestor.txt
index 4aa47e7c2..20f9dbee8 100644
--- a/tests/functional/d/dotted_ancestor.txt
+++ b/tests/functional/d/dotted_ancestor.txt
@@ -1 +1 @@
-too-few-public-methods:8:0:Aaaa:Too few public methods (0/2)
+too-few-public-methods:7:0:Aaaa:Too few public methods (0/2):HIGH
diff --git a/tests/functional/g/generated_members.rc b/tests/functional/g/generated_members.rc
index 8b61b4996..31b87ffd0 100644
--- a/tests/functional/g/generated_members.rc
+++ b/tests/functional/g/generated_members.rc
@@ -1,5 +1,5 @@
[Messages Control]
-disable=too-few-public-methods,print-statement
+disable=too-few-public-methods
[typecheck]
generated-members=
diff --git a/tests/functional/i/import_error.py b/tests/functional/i/import_error.py
index 09bf5560e..21c06d1e3 100644
--- a/tests/functional/i/import_error.py
+++ b/tests/functional/i/import_error.py
@@ -1,5 +1,5 @@
""" Test that import errors are detected. """
-# pylint: disable=invalid-name, unused-import, no-absolute-import, bare-except, broad-except, wrong-import-order, wrong-import-position
+# pylint: disable=invalid-name, unused-import, bare-except, broad-except, wrong-import-order, wrong-import-position
import totally_missing # [import-error]
try:
diff --git a/tests/functional/i/import_itself.py b/tests/functional/i/import_itself.py
index becd529d7..1f4928f3e 100644
--- a/tests/functional/i/import_itself.py
+++ b/tests/functional/i/import_itself.py
@@ -1,5 +1,5 @@
"""test module importing itself"""
-# pylint: disable=no-absolute-import,using-constant-test
+# pylint: disable=using-constant-test
from __future__ import print_function
from . import import_itself # [import-self]
diff --git a/tests/functional/i/inherit_non_class.py b/tests/functional/i/inherit_non_class.py
index ee9ef508c..bbee6bd9a 100644
--- a/tests/functional/i/inherit_non_class.py
+++ b/tests/functional/i/inherit_non_class.py
@@ -2,7 +2,7 @@
a class emits a warning. """
# pylint: disable=no-init, import-error, invalid-name, using-constant-test, useless-object-inheritance
-# pylint: disable=missing-docstring, too-few-public-methods, no-absolute-import
+# pylint: disable=missing-docstring, too-few-public-methods
from missing import Missing
diff --git a/tests/functional/i/invalid/e/invalid_exceptions_caught.py b/tests/functional/i/invalid/e/invalid_exceptions_caught.py
index 5cb6c84b8..c0298a06e 100644
--- a/tests/functional/i/invalid/e/invalid_exceptions_caught.py
+++ b/tests/functional/i/invalid/e/invalid_exceptions_caught.py
@@ -1,5 +1,5 @@
# pylint: disable=missing-docstring, too-few-public-methods, useless-object-inheritance, use-list-literal
-# pylint: disable=too-many-ancestors, no-absolute-import, import-error, multiple-imports,wrong-import-position
+# pylint: disable=too-many-ancestors, import-error, multiple-imports,wrong-import-position
from __future__ import print_function
import socket, binascii, abc, six
diff --git a/tests/functional/i/invalid/invalid_name.py b/tests/functional/i/invalid/invalid_name.py
index 07ad99b80..9ec81bfbf 100644
--- a/tests/functional/i/invalid/invalid_name.py
+++ b/tests/functional/i/invalid/invalid_name.py
@@ -1,5 +1,5 @@
""" Tests for invalid-name checker. """
-# pylint: disable=unused-import, no-absolute-import, wrong-import-position,import-outside-toplevel
+# pylint: disable=unused-import, wrong-import-position,import-outside-toplevel
AAA = 24
try:
diff --git a/tests/functional/l/len_checks.py b/tests/functional/l/len_checks.py
index 2cbefcbe7..ceeedb549 100644
--- a/tests/functional/l/len_checks.py
+++ b/tests/functional/l/len_checks.py
@@ -1,4 +1,4 @@
-# pylint: disable=too-few-public-methods,import-error, no-absolute-import,missing-docstring, misplaced-comparison-constant
+# pylint: disable=too-few-public-methods,import-error, missing-docstring, misplaced-comparison-constant
# pylint: disable=useless-super-delegation,wrong-import-position,invalid-name, wrong-import-order, condition-evals-to-constant
if len('TEST'): # [len-as-condition]
diff --git a/tests/functional/l/logging_format_interpolation.py b/tests/functional/l/logging_format_interpolation.py
index 782e3834b..5670ad57c 100644
--- a/tests/functional/l/logging_format_interpolation.py
+++ b/tests/functional/l/logging_format_interpolation.py
@@ -1,4 +1,4 @@
-# pylint: disable=no-member, no-absolute-import, import-error,line-too-long
+# pylint: disable=no-member, import-error,line-too-long
# pylint: disable=invalid-name,missing-docstring,wrong-import-order,wrong-import-position, consider-using-f-string
try:
import __builtin__ as builtins
diff --git a/tests/functional/m/member/member_checks.py b/tests/functional/m/member/member_checks.py
index ee79d1012..c1b6a22fb 100644
--- a/tests/functional/m/member/member_checks.py
+++ b/tests/functional/m/member/member_checks.py
@@ -1,4 +1,4 @@
-# pylint: disable=print-statement,missing-docstring,no-self-use,too-few-public-methods,bare-except,broad-except, useless-object-inheritance, unused-private-member
+# pylint: disable=missing-docstring,no-self-use,too-few-public-methods,bare-except,broad-except, useless-object-inheritance, unused-private-member
# pylint: disable=using-constant-test,expression-not-assigned, assigning-non-slot, unused-variable,pointless-statement, wrong-import-order, wrong-import-position,import-outside-toplevel
from __future__ import print_function
class Provider(object):
diff --git a/tests/functional/m/metaclass_attr_access.py b/tests/functional/m/metaclass_attr_access.py
index e6bf1cccb..50f9712fa 100644
--- a/tests/functional/m/metaclass_attr_access.py
+++ b/tests/functional/m/metaclass_attr_access.py
@@ -1,9 +1,9 @@
-# pylint: disable=too-few-public-methods, metaclass-assignment, useless-object-inheritance
+# pylint: disable=too-few-public-methods, useless-object-inheritance
"""test attribute access on metaclass"""
-
from __future__ import print_function
+
class Meta(type):
"""the meta class"""
def __init__(cls, name, bases, dictionary):
@@ -11,6 +11,7 @@ class Meta(type):
print(cls, cls._meta_args)
delattr(cls, '_meta_args')
+
class Test(object):
"""metaclassed class"""
__metaclass__ = Meta
diff --git a/tests/functional/m/method_hidden.py b/tests/functional/m/method_hidden.py
index 47031d8d0..cdbe323e2 100644
--- a/tests/functional/m/method_hidden.py
+++ b/tests/functional/m/method_hidden.py
@@ -1,4 +1,4 @@
-# pylint: disable=too-few-public-methods,print-statement, useless-object-inheritance,missing-docstring
+# pylint: disable=too-few-public-methods, useless-object-inheritance,missing-docstring
"""check method hidding ancestor attribute
"""
from __future__ import print_function
diff --git a/tests/functional/n/name/name_styles.py b/tests/functional/n/name/name_styles.py
index a9d74356c..27e6e1044 100644
--- a/tests/functional/n/name/name_styles.py
+++ b/tests/functional/n/name/name_styles.py
@@ -1,5 +1,5 @@
"""Test for the invalid-name warning."""
-# pylint: disable=no-absolute-import, useless-object-inheritance, unnecessary-pass, unnecessary-comprehension, unused-private-member
+# pylint: disable= useless-object-inheritance, unnecessary-pass, unnecessary-comprehension, unused-private-member
from __future__ import print_function
import abc
import collections
diff --git a/tests/functional/n/name/names_in__all__.py b/tests/functional/n/name/names_in__all__.py
index 9b2840acc..c5d17cd80 100644
--- a/tests/functional/n/name/names_in__all__.py
+++ b/tests/functional/n/name/names_in__all__.py
@@ -1,4 +1,4 @@
-# pylint: disable=too-few-public-methods,no-self-use, no-absolute-import,import-error, useless-object-inheritance, unnecessary-pass
+# pylint: disable=too-few-public-methods,no-self-use, import-error, useless-object-inheritance, unnecessary-pass
"""Test Pylint's use of __all__.
* NonExistant is not defined in this module, and it is listed in
diff --git a/tests/functional/n/new_style_class_py_30.py b/tests/functional/n/new_style_class_py_30.py
index 7a2a59a17..b70c6e097 100644
--- a/tests/functional/n/new_style_class_py_30.py
+++ b/tests/functional/n/new_style_class_py_30.py
@@ -6,7 +6,7 @@ from __future__ import print_function
__revision__ = None
-class File(file): # pylint: disable=file-builtin,undefined-variable
+class File(file): # pylint: disable=undefined-variable
""" Testing new-style class inheritance from file"""
def __init__(self, name, mode="r", buffering=-1, verbose=False):
"""Constructor"""
diff --git a/tests/functional/n/no/no_name_in_module.py b/tests/functional/n/no/no_name_in_module.py
index e3ea9469b..ba67fbdb7 100644
--- a/tests/functional/n/no/no_name_in_module.py
+++ b/tests/functional/n/no/no_name_in_module.py
@@ -1,4 +1,4 @@
-# pylint: disable=wildcard-import,unused-import,no-absolute-import,invalid-name,import-error,
+# pylint: disable=wildcard-import,unused-import,invalid-name,import-error
# pylint: disable=bare-except,broad-except,wrong-import-order,ungrouped-imports,wrong-import-position
"""check nonexistent names imported are reported"""
from __future__ import print_function
diff --git a/tests/functional/n/non/non_init_parent_called.py b/tests/functional/n/non/non_init_parent_called.py
index 1ecc8f16a..97489accf 100644
--- a/tests/functional/n/non/non_init_parent_called.py
+++ b/tests/functional/n/non/non_init_parent_called.py
@@ -1,5 +1,5 @@
# pylint: disable=protected-access,import-self,too-few-public-methods,line-too-long
-# pylint: disable=no-absolute-import,wrong-import-order, useless-object-inheritance,
+# pylint: disable=wrong-import-order, useless-object-inheritance,
"""test for call to __init__ from a non ancestor class
"""
from __future__ import print_function
diff --git a/tests/functional/n/nonlocal_without_binding.py b/tests/functional/n/nonlocal_without_binding.py
index be3c00371..22887bcee 100644
--- a/tests/functional/n/nonlocal_without_binding.py
+++ b/tests/functional/n/nonlocal_without_binding.py
@@ -1,6 +1,6 @@
""" Checks that reversed() receive proper argument """
# pylint: disable=missing-docstring,invalid-name,unused-variable, useless-object-inheritance
-# pylint: disable=too-few-public-methods,no-self-use,no-absolute-import
+# pylint: disable=too-few-public-methods,no-self-use
def test():
def parent():
diff --git a/tests/functional/s/slots_checks.py b/tests/functional/s/slots_checks.py
index c8cfd04e0..79912b65c 100644
--- a/tests/functional/s/slots_checks.py
+++ b/tests/functional/s/slots_checks.py
@@ -1,6 +1,6 @@
""" Checks that classes uses valid __slots__ """
-# pylint: disable=too-few-public-methods, missing-docstring, no-absolute-import, useless-object-inheritance
+# pylint: disable=too-few-public-methods, missing-docstring, useless-object-inheritance
# pylint: disable=using-constant-test, wrong-import-position, no-else-return, line-too-long, unused-private-member
from collections import deque
diff --git a/tests/functional/s/string/string_formatting.py b/tests/functional/s/string/string_formatting.py
index 6d2b18665..8372a4373 100644
--- a/tests/functional/s/string/string_formatting.py
+++ b/tests/functional/s/string/string_formatting.py
@@ -1,6 +1,6 @@
"""Test for Python 3 string formatting error"""
-# pylint: disable=too-few-public-methods, import-error, unused-argument, line-too-long, no-absolute-import,
+# pylint: disable=too-few-public-methods, import-error, unused-argument, line-too-long,
# pylint: disable=useless-object-inheritance, consider-using-f-string
import os
import sys
diff --git a/tests/functional/s/string/string_formatting_error.py b/tests/functional/s/string/string_formatting_error.py
index d48b47d3f..681fedd56 100644
--- a/tests/functional/s/string/string_formatting_error.py
+++ b/tests/functional/s/string/string_formatting_error.py
@@ -1,5 +1,5 @@
"""test string format error"""
-# pylint: disable=print-statement,unsupported-binary-operation,line-too-long, consider-using-f-string
+# pylint: disable=unsupported-binary-operation,line-too-long, consider-using-f-string
from __future__ import print_function
PARG_1 = PARG_2 = PARG_3 = 1
diff --git a/tests/functional/s/string/string_log_formatting.py b/tests/functional/s/string/string_log_formatting.py
index e03d47f59..3bed980f7 100644
--- a/tests/functional/s/string/string_log_formatting.py
+++ b/tests/functional/s/string/string_log_formatting.py
@@ -1,15 +1,15 @@
-# pylint: disable=no-absolute-import
-"""Test checking of log format strings
+"""
+Test checking of log format strings
"""
import logging
-__revision__ = ''
-
def pprint():
- """Test string format in logging statements.
"""
+ Test string format in logging statements.
+ """
+
# These should all emit lint errors:
logging.info(0, '') # [logging-too-many-args]
logging.info('', '') # [logging-too-many-args]
diff --git a/tests/functional/s/super/super_checks.py b/tests/functional/s/super/super_checks.py
index 3f132dff1..277feae7e 100644
--- a/tests/functional/s/super/super_checks.py
+++ b/tests/functional/s/super/super_checks.py
@@ -1,4 +1,4 @@
-# pylint: disable=too-few-public-methods,import-error, no-absolute-import,missing-docstring, useless-object-inheritance
+# pylint: disable=too-few-public-methods,import-error, missing-docstring, useless-object-inheritance
# pylint: disable=useless-super-delegation,wrong-import-position,invalid-name, wrong-import-order
# pylint: disable=super-with-arguments
from unknown import Missing
diff --git a/tests/functional/u/unpacking_non_sequence.py b/tests/functional/u/unpacking_non_sequence.py
index c681641ca..b7ea2189c 100644
--- a/tests/functional/u/unpacking_non_sequence.py
+++ b/tests/functional/u/unpacking_non_sequence.py
@@ -1,6 +1,6 @@
"""Check unpacking non-sequences in assignments. """
-# pylint: disable=too-few-public-methods, invalid-name, attribute-defined-outside-init, unused-variable, no-absolute-import
+# pylint: disable=too-few-public-methods, invalid-name, attribute-defined-outside-init, unused-variable
# pylint: disable=using-constant-test, no-init, missing-docstring, wrong-import-order,wrong-import-position,no-else-return, useless-object-inheritance
from os import rename as nonseq_func
from functional.u.unpacking import nonseq
diff --git a/tests/functional/u/unused/unused_argument.py b/tests/functional/u/unused/unused_argument.py
index c5f534259..a3fd4e6ab 100644
--- a/tests/functional/u/unused/unused_argument.py
+++ b/tests/functional/u/unused/unused_argument.py
@@ -47,7 +47,7 @@ def metadata_from_dict(key):
"""
return {key: str(value) for key, value in key.items()}
-# pylint: disable=too-few-public-methods, print-statement, misplaced-future,wrong-import-position
+# pylint: disable=too-few-public-methods, misplaced-future,wrong-import-position
from __future__ import print_function
diff --git a/tests/functional/u/unused/unused_import.py b/tests/functional/u/unused/unused_import.py
index c6c2f20be..3bf17c6c9 100644
--- a/tests/functional/u/unused/unused_import.py
+++ b/tests/functional/u/unused/unused_import.py
@@ -1,5 +1,5 @@
"""unused import"""
-# pylint: disable=undefined-all-variable, import-error, no-absolute-import, too-few-public-methods, missing-docstring,wrong-import-position, useless-object-inheritance, multiple-imports
+# pylint: disable=undefined-all-variable, import-error, too-few-public-methods, missing-docstring,wrong-import-position, useless-object-inheritance, multiple-imports
import xml.etree # [unused-import]
import xml.sax # [unused-import]
import os.path as test # [unused-import]
diff --git a/tests/functional/u/unused/unused_name_from_wilcard_import.py b/tests/functional/u/unused/unused_name_from_wilcard_import.py
index 56f5b600e..292d40f95 100644
--- a/tests/functional/u/unused/unused_name_from_wilcard_import.py
+++ b/tests/functional/u/unused/unused_name_from_wilcard_import.py
@@ -1,3 +1,3 @@
"""check unused import from a wildcard import"""
-# pylint: disable=no-absolute-import,line-too-long
+# pylint: disable=line-too-long
from .unused_argument_py3 import * # [unused-wildcard-import, unused-wildcard-import, wildcard-import]
diff --git a/tests/functional/w/wildcard_import.py b/tests/functional/w/wildcard_import.py
index 66ae63d9e..4034162e0 100644
--- a/tests/functional/w/wildcard_import.py
+++ b/tests/functional/w/wildcard_import.py
@@ -1,4 +1,4 @@
-# pylint: disable=no-absolute-import,missing-docstring,import-error,unused-wildcard-import
+# pylint: disable=missing-docstring,import-error,unused-wildcard-import
from indirect1 import * # [wildcard-import]
# This is an unresolved import which still generates the wildcard-import
# warning.
diff --git a/tests/input/func_3k_removed_stuff_py_30.py b/tests/input/func_3k_removed_stuff_py_30.py
index 54ad935bc..d844c5603 100644
--- a/tests/input/func_3k_removed_stuff_py_30.py
+++ b/tests/input/func_3k_removed_stuff_py_30.py
@@ -1,5 +1,5 @@
"""test relative import"""
-# pylint: disable=no-absolute-import
+
from __future__ import print_function
import func_w0401
__revision__ = filter(None, map(str, (1, 2, 3)))
diff --git a/tests/input/func_w0332_py_30.py b/tests/input/func_w0332_py_30.py
deleted file mode 100644
index 6a38e8c0d..000000000
--- a/tests/input/func_w0332_py_30.py
+++ /dev/null
@@ -1,4 +0,0 @@
-"""check use of l as long int marker
-"""
-# pylint: disable=long-suffix
-__revision__ = 1l
diff --git a/tests/input/func_w0401.py b/tests/input/func_w0401.py
index 12227bc9a..f8fae2447 100644
--- a/tests/input/func_w0401.py
+++ b/tests/input/func_w0401.py
@@ -1,6 +1,6 @@
"""test cyclic import
"""
-# pylint: disable=no-absolute-import
+
from __future__ import print_function
from . import w0401_cycle
diff --git a/tests/input/func_w0401_disabled.py b/tests/input/func_w0401_disabled.py
index 966706caf..955188f08 100644
--- a/tests/input/func_w0401_disabled.py
+++ b/tests/input/func_w0401_disabled.py
@@ -1,6 +1,6 @@
"""test cyclic import
"""
-# pylint: disable=no-absolute-import
+
from __future__ import print_function
from . import w0401_cycle # pylint: disable=cyclic-import
diff --git a/tests/input/func_w0401_disabled_in_func.py b/tests/input/func_w0401_disabled_in_func.py
index 69f266863..c0013d831 100644
--- a/tests/input/func_w0401_disabled_in_func.py
+++ b/tests/input/func_w0401_disabled_in_func.py
@@ -1,6 +1,6 @@
"""Test disabling of cyclic import check inside a function
"""
-# pylint: disable=no-absolute-import,import-outside-toplevel
+# pylint: disable=import-outside-toplevel
from __future__ import print_function
diff --git a/tests/input/func_w0401_package/all_the_things.py b/tests/input/func_w0401_package/all_the_things.py
index b8bd47b9e..64556e1be 100644
--- a/tests/input/func_w0401_package/all_the_things.py
+++ b/tests/input/func_w0401_package/all_the_things.py
@@ -1,5 +1,5 @@
"""All the things!"""
-# pylint: disable=no-absolute-import
+
from .thing1 import THING1
from .thing2 import THING2
from .thing2 import THING1_PLUS_THING2
diff --git a/tests/input/func_w0401_package/thing2.py b/tests/input/func_w0401_package/thing2.py
index 80bec1dd8..d7a0f2239 100644
--- a/tests/input/func_w0401_package/thing2.py
+++ b/tests/input/func_w0401_package/thing2.py
@@ -1,5 +1,5 @@
"""The second thing."""
-# pylint: disable=no-absolute-import
+
from .all_the_things import THING1
__revision__ = None
diff --git a/tests/input/no_absolute_import.py b/tests/input/no_absolute_import.py
deleted file mode 100644
index 69059417f..000000000
--- a/tests/input/no_absolute_import.py
+++ /dev/null
@@ -1,5 +0,0 @@
-""" Puts issue #2672 under test (-j 1 vs -j N)
-
-Here we use a simple file to ensure configs are treated exactly the same way in -j 1 and
--j N """
-import os # pylint: disable=unused-import
diff --git a/tests/input/w0401_cycle.py b/tests/input/w0401_cycle.py
index ddb42557e..37be7c562 100644
--- a/tests/input/w0401_cycle.py
+++ b/tests/input/w0401_cycle.py
@@ -1,6 +1,6 @@
"""w0401 dependency
"""
-# pylint: disable=print-statement, no-absolute-import
+
from __future__ import print_function
from . import func_w0401
diff --git a/tests/lint/unittest_lint.py b/tests/lint/unittest_lint.py
index fee47c9cf..110a2061c 100644
--- a/tests/lint/unittest_lint.py
+++ b/tests/lint/unittest_lint.py
@@ -575,15 +575,6 @@ def test_analyze_explicit_script(linter):
assert ["C: 2: Line too long (175/100)"] == linter.reporter.messages
-def test_python3_checker_disabled(linter):
- checker_names = [c.name for c in linter.prepare_checkers()]
- assert "python3" not in checker_names
-
- linter.set_option("enable", "python3")
- checker_names = [c.name for c in linter.prepare_checkers()]
- assert "python3" in checker_names
-
-
def test_full_documentation(linter):
out = StringIO()
linter.print_full_documentation(out)
@@ -592,9 +583,9 @@ def test_full_documentation(linter):
for re_str in (
# autogenerated text
"^Pylint global options and switches$",
- "Verbatim name of the checker is ``python3``",
+ "Verbatim name of the checker is ``variables``",
# messages
- "^:old-octal-literal \\(E1608\\):",
+ "^:undefined-loop-variable \\(W0631\\): *",
# options
"^:dummy-variables-rgx:",
):
diff --git a/tests/regrtest_data/func_block_disable_msg.py b/tests/regrtest_data/func_block_disable_msg.py
index 36198db2b..8a94ab4f3 100644
--- a/tests/regrtest_data/func_block_disable_msg.py
+++ b/tests/regrtest_data/func_block_disable_msg.py
@@ -1,4 +1,4 @@
-# pylint: disable=C0302,bare-except,print-statement, useless-object-inheritance
+# pylint: disable=C0302,bare-except, useless-object-inheritance
"""pylint option block-disable"""
from __future__ import print_function
diff --git a/tests/regrtest_data/py3k-disabled.rc b/tests/regrtest_data/py3k-disabled.rc
deleted file mode 100644
index 41d775778..000000000
--- a/tests/regrtest_data/py3k-disabled.rc
+++ /dev/null
@@ -1,2 +0,0 @@
-[MESSAGES CONTROL]
-disable=no-absolute-import
diff --git a/tests/regrtest_data/py3k_error_flag.py b/tests/regrtest_data/py3k_error_flag.py
deleted file mode 100644
index 6bead4102..000000000
--- a/tests/regrtest_data/py3k_error_flag.py
+++ /dev/null
@@ -1,11 +0,0 @@
-"""Contains both normal error messages and Python3 porting error messages."""
-# pylint: disable=too-few-public-methods
-
-raise Exception, 1 # Error emitted here with the Python 3 checker.
-
-
-class Test(object):
- """dummy"""
-
- def __init__(self):
- return 42
diff --git a/tests/regrtest_data/py3k_errors_and_warnings.py b/tests/regrtest_data/py3k_errors_and_warnings.py
deleted file mode 100644
index 3d033e86c..000000000
--- a/tests/regrtest_data/py3k_errors_and_warnings.py
+++ /dev/null
@@ -1,19 +0,0 @@
-"""Contains both normal error messages and Python3 porting error messages."""
-# pylint: disable=too-few-public-methods
-
-# error: import missing `from __future__ import absolute_import`
-import sys
-
-# error: Use raise ErrorClass(args) instead of raise ErrorClass, args.
-raise Exception, 1
-
-class Test(object):
- """dummy"""
-
- def __init__(self):
- # warning: Calling a dict.iter*() method
- {1: 2}.iteritems()
- return 42
-
-# error: print statement used
-print 'not in python3'
diff --git a/tests/test_self.py b/tests/test_self.py
index 519899021..2bf635176 100644
--- a/tests/test_self.py
+++ b/tests/test_self.py
@@ -290,32 +290,9 @@ class TestRunTC:
in out.getvalue().strip()
)
- def test_parallel_execution_bug_2674(self):
- """Tests that disabling absolute imports works the same in -j1/j2"""
- expected_ret_code = 0 # we are disabling the check, should pass
- for jobs in (1, 2):
- self._runtest(
- [
- "--py3k",
- "--disable=no-absolute-import",
- f"-j {int(jobs)}",
- join(HERE, "input", "no_absolute_import.py"),
- ],
- code=expected_ret_code,
- )
-
def test_parallel_execution_missing_arguments(self):
self._runtest(["-j 2", "not_here", "not_here_too"], code=1)
- def test_py3k_option(self):
- # Test that --py3k flag works.
- rc_code = 0
- self._runtest([UNNECESSARY_LAMBDA, "--py3k"], code=rc_code)
-
- def test_py3k_jobs_option(self):
- rc_code = 0
- self._runtest([UNNECESSARY_LAMBDA, "--py3k", "-j 2"], code=rc_code)
-
def test_abbreviations_are_not_supported(self):
expected = "no such option: --load-plugin"
self._test_output([".", "--load-plugin"], expected_output=expected)