summaryrefslogtreecommitdiff
path: root/tests/checkers/unittest_format.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/checkers/unittest_format.py')
-rw-r--r--tests/checkers/unittest_format.py29
1 files changed, 15 insertions, 14 deletions
diff --git a/tests/checkers/unittest_format.py b/tests/checkers/unittest_format.py
index 658a7e3f4..4023207bb 100644
--- a/tests/checkers/unittest_format.py
+++ b/tests/checkers/unittest_format.py
@@ -31,6 +31,7 @@
import os
import tempfile
import tokenize
+from typing import Any
import astroid
@@ -42,7 +43,7 @@ from pylint.testutils import CheckerTestCase, Message, _tokenize_str
class TestMultiStatementLine(CheckerTestCase):
CHECKER_CLASS = FormatChecker
- def testSingleLineIfStmts(self):
+ def testSingleLineIfStmts(self) -> None:
stmt = astroid.extract_node(
"""
if True: pass #@
@@ -64,7 +65,7 @@ class TestMultiStatementLine(CheckerTestCase):
with self.assertAddsMessages(Message("multiple-statements", node=stmt.body[0])):
self.visitFirst(stmt)
- def testSingleLineClassStmts(self):
+ def testSingleLineClassStmts(self) -> None:
stmt = astroid.extract_node(
"""
class MyError(Exception): pass #@
@@ -101,7 +102,7 @@ class TestMultiStatementLine(CheckerTestCase):
with self.assertAddsMessages(Message("multiple-statements", node=stmt.body[0])):
self.visitFirst(stmt)
- def testTryExceptFinallyNoMultipleStatement(self):
+ def testTryExceptFinallyNoMultipleStatement(self) -> None:
tree = astroid.extract_node(
"""
try: #@
@@ -114,11 +115,11 @@ class TestMultiStatementLine(CheckerTestCase):
with self.assertNoMessages():
self.visitFirst(tree)
- def visitFirst(self, tree):
+ def visitFirst(self, tree: Any) -> None:
self.checker.process_tokens([])
self.checker.visit_default(tree.body[0])
- def test_ellipsis_is_ignored(self):
+ def test_ellipsis_is_ignored(self) -> None:
code = """
from typing import overload
@overload
@@ -139,7 +140,7 @@ class TestMultiStatementLine(CheckerTestCase):
class TestSuperfluousParentheses(CheckerTestCase):
CHECKER_CLASS = FormatChecker
- def testCheckKeywordParensHandlesValidCases(self):
+ def testCheckKeywordParensHandlesValidCases(self) -> None:
cases = [
"if foo:",
"if foo():",
@@ -160,7 +161,7 @@ class TestSuperfluousParentheses(CheckerTestCase):
for code in cases:
self.checker._check_keyword_parentheses(_tokenize_str(code), 0)
- def testCheckKeywordParensHandlesUnnecessaryParens(self):
+ def testCheckKeywordParensHandlesUnnecessaryParens(self) -> None:
cases = [
(Message("superfluous-parens", line=1, args="if"), "if (foo):", 0),
(Message("superfluous-parens", line=1, args="if"), "if ((foo, bar)):", 0),
@@ -184,7 +185,7 @@ class TestSuperfluousParentheses(CheckerTestCase):
with self.assertAddsMessages(msg):
self.checker._check_keyword_parentheses(_tokenize_str(code), offset)
- def testNoSuperfluousParensWalrusOperatorIf(self):
+ def testNoSuperfluousParensWalrusOperatorIf(self) -> None:
"""Parenthesis change the meaning of assignment in the walrus operator
and so are not always superfluous:"""
cases = [
@@ -195,7 +196,7 @@ class TestSuperfluousParentheses(CheckerTestCase):
with self.assertNoMessages():
self.checker.process_tokens(_tokenize_str(code))
- def testPositiveSuperfluousParensWalrusOperatorIf(self):
+ def testPositiveSuperfluousParensWalrusOperatorIf(self) -> None:
"""Test positive superfluous parens cases with the walrus operator"""
cases = [
(Message("superfluous-parens", line=1, args="if"), "if ((x := y)):\n"),
@@ -205,7 +206,7 @@ class TestSuperfluousParentheses(CheckerTestCase):
with self.assertAddsMessages(msg):
self.checker.process_tokens(_tokenize_str(code))
- def testCheckIfArgsAreNotUnicode(self):
+ def testCheckIfArgsAreNotUnicode(self) -> None:
cases = [("if (foo):", 0), ("assert (1 == 1)", 0)]
for code, offset in cases:
@@ -213,7 +214,7 @@ class TestSuperfluousParentheses(CheckerTestCase):
got = self.linter.release_messages()
assert isinstance(got[-1].args, str)
- def testFuturePrintStatementWithoutParensWarning(self):
+ def testFuturePrintStatementWithoutParensWarning(self) -> None:
code = """from __future__ import print_function
print('Hello world!')
"""
@@ -222,7 +223,7 @@ print('Hello world!')
self.checker.process_module(tree)
self.checker.process_tokens(_tokenize_str(code))
- def testKeywordParensFalsePositive(self):
+ def testKeywordParensFalsePositive(self) -> None:
code = "if 'bar' in (DICT or {}):"
with self.assertNoMessages():
self.checker._check_keyword_parentheses(_tokenize_str(code), start=2)
@@ -231,7 +232,7 @@ print('Hello world!')
class TestCheckSpace(CheckerTestCase):
CHECKER_CLASS = FormatChecker
- def test_encoding_token(self):
+ def test_encoding_token(self) -> None:
"""Make sure the encoding token doesn't change the checker's behavior
_tokenize_str doesn't produce an encoding token, but
@@ -247,7 +248,7 @@ class TestCheckSpace(CheckerTestCase):
self.checker.process_tokens(tokens)
-def test_disable_global_option_end_of_line():
+def test_disable_global_option_end_of_line() -> None:
"""
Test for issue with disabling tokenizer messages
that extend beyond the scope of the ast tokens