summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorPierre Sassoulas <pierre.sassoulas@gmail.com>2020-05-02 20:15:48 +0200
committerPierre Sassoulas <pierre.sassoulas@gmail.com>2020-05-03 10:38:06 +0200
commitdb9b9849b54cb162616d6d2706b98533066ef4d8 (patch)
treeb01c3d409009103bd3ee2253b9002b88549cd081 /tests
parent7885d56f33b7757d7ebe4dec960d3589f28579ed (diff)
downloadpylint-git-db9b9849b54cb162616d6d2706b98533066ef4d8.tar.gz
Remove all tests concerning bad-whitespace
Diffstat (limited to 'tests')
-rw-r--r--tests/checkers/unittest_format.py259
-rw-r--r--tests/functional/b/bad_whitespace.py7
-rw-r--r--tests/functional/b/bad_whitespace.txt15
3 files changed, 1 insertions, 280 deletions
diff --git a/tests/checkers/unittest_format.py b/tests/checkers/unittest_format.py
index 2494b4daf..5009279f7 100644
--- a/tests/checkers/unittest_format.py
+++ b/tests/checkers/unittest_format.py
@@ -33,7 +33,7 @@ import astroid
from pylint import lint, reporters
from pylint.checkers.format import FormatChecker
-from pylint.testutils import CheckerTestCase, Message, _tokenize_str, set_config
+from pylint.testutils import CheckerTestCase, Message, _tokenize_str
class TestMultiStatementLine(CheckerTestCase):
@@ -214,263 +214,6 @@ print('Hello world!')
class TestCheckSpace(CheckerTestCase):
CHECKER_CLASS = FormatChecker
- def testParenthesesGood(self):
- good_cases = ["(a)\n", "(a * (b + c))\n", "(#\n a)\n"]
- with self.assertNoMessages():
- for code in good_cases:
- self.checker.process_tokens(_tokenize_str(code))
-
- def testParenthesesBad(self):
- with self.assertAddsMessages(
- Message(
- "bad-whitespace",
- line=1,
- args=("No", "allowed", "after", "bracket", "( a)\n^"),
- )
- ):
- self.checker.process_tokens(_tokenize_str("( a)\n"))
-
- with self.assertAddsMessages(
- Message(
- "bad-whitespace",
- line=1,
- args=("No", "allowed", "before", "bracket", "(a )\n ^"),
- )
- ):
- self.checker.process_tokens(_tokenize_str("(a )\n"))
-
- with self.assertAddsMessages(
- Message(
- "bad-whitespace",
- line=1,
- args=("No", "allowed", "before", "bracket", "foo (a)\n ^"),
- )
- ):
- self.checker.process_tokens(_tokenize_str("foo (a)\n"))
-
- with self.assertAddsMessages(
- Message(
- "bad-whitespace",
- line=1,
- args=("No", "allowed", "before", "bracket", "{1: 2} [1]\n ^"),
- )
- ):
- self.checker.process_tokens(_tokenize_str("{1: 2} [1]\n"))
-
- def testTrailingCommaGood(self):
- with self.assertNoMessages():
- self.checker.process_tokens(_tokenize_str("(a, )\n"))
- self.checker.process_tokens(_tokenize_str("(a,)\n"))
-
- self.checker.config.no_space_check = []
- with self.assertNoMessages():
- self.checker.process_tokens(_tokenize_str("(a,)\n"))
-
- @set_config(no_space_check=[])
- def testTrailingCommaBad(self):
- with self.assertAddsMessages(
- Message(
- "bad-whitespace",
- line=1,
- args=("No", "allowed", "before", "bracket", "(a, )\n ^"),
- )
- ):
- self.checker.process_tokens(_tokenize_str("(a, )\n"))
-
- def testComma(self):
- with self.assertAddsMessages(
- Message(
- "bad-whitespace",
- line=1,
- args=("No", "allowed", "before", "comma", "(a , b)\n ^"),
- )
- ):
- self.checker.process_tokens(_tokenize_str("(a , b)\n"))
-
- def testSpacesAllowedInsideSlices(self):
- good_cases = ["[a:b]\n", "[a : b]\n", "[a : ]\n", "[:a]\n", "[:]\n", "[::]\n"]
- with self.assertNoMessages():
- for code in good_cases:
- self.checker.process_tokens(_tokenize_str(code))
-
- def testKeywordSpacingGood(self):
- with self.assertNoMessages():
- self.checker.process_tokens(_tokenize_str("foo(foo=bar)\n"))
- self.checker.process_tokens(_tokenize_str("foo(foo: int = bar)\n"))
- self.checker.process_tokens(
- _tokenize_str("foo(foo: module.classname = bar)\n")
- )
- self.checker.process_tokens(
- _tokenize_str("foo(foo: Dict[int, str] = bar)\n")
- )
- self.checker.process_tokens(_tokenize_str("foo(foo: 'int' = bar)\n"))
- self.checker.process_tokens(
- _tokenize_str("foo(foo: Dict[int, 'str'] = bar)\n")
- )
- self.checker.process_tokens(_tokenize_str("lambda x=1: x\n"))
-
- def testKeywordSpacingBad(self):
- with self.assertAddsMessages(
- Message(
- "bad-whitespace",
- line=1,
- args=(
- "No",
- "allowed",
- "before",
- "keyword argument assignment",
- "(foo =bar)\n ^",
- ),
- )
- ):
- self.checker.process_tokens(_tokenize_str("(foo =bar)\n"))
-
- with self.assertAddsMessages(
- Message(
- "bad-whitespace",
- line=1,
- args=(
- "No",
- "allowed",
- "after",
- "keyword argument assignment",
- "(foo= bar)\n ^",
- ),
- )
- ):
- self.checker.process_tokens(_tokenize_str("(foo= bar)\n"))
-
- with self.assertAddsMessages(
- Message(
- "bad-whitespace",
- line=1,
- args=(
- "No",
- "allowed",
- "around",
- "keyword argument assignment",
- "(foo = bar)\n ^",
- ),
- )
- ):
- self.checker.process_tokens(_tokenize_str("(foo = bar)\n"))
-
- with self.assertAddsMessages(
- Message(
- "bad-whitespace",
- line=1,
- args=(
- "Exactly one",
- "required",
- "before",
- "keyword argument assignment",
- "(foo: int= bar)\n ^",
- ),
- )
- ):
- self.checker.process_tokens(_tokenize_str("(foo: int= bar)\n"))
-
- with self.assertAddsMessages(
- Message(
- "bad-whitespace",
- line=1,
- args=(
- "Exactly one",
- "required",
- "after",
- "keyword argument assignment",
- "(foo: int =bar)\n ^",
- ),
- )
- ):
- self.checker.process_tokens(_tokenize_str("(foo: int =bar)\n"))
-
- with self.assertAddsMessages(
- Message(
- "bad-whitespace",
- line=1,
- args=(
- "Exactly one",
- "required",
- "around",
- "keyword argument assignment",
- "(foo: int=bar)\n ^",
- ),
- )
- ):
- self.checker.process_tokens(_tokenize_str("(foo: int=bar)\n"))
-
- with self.assertAddsMessages(
- Message(
- "bad-whitespace",
- line=1,
- args=(
- "Exactly one",
- "required",
- "around",
- "keyword argument assignment",
- "(foo: List[int]=bar)\n ^",
- ),
- )
- ):
- self.checker.process_tokens(_tokenize_str("(foo: List[int]=bar)\n"))
- # Regression test for #1831
- with self.assertNoMessages():
- self.checker.process_tokens(
- _tokenize_str("(arg: Tuple[\n int, str] = None):\n")
- )
-
- def testOperatorSpacingGood(self):
- good_cases = ["a = b\n", "a < b\n", "a\n< b\n"]
- with self.assertNoMessages():
- for code in good_cases:
- self.checker.process_tokens(_tokenize_str(code))
-
- def testOperatorSpacingBad(self):
- with self.assertAddsMessages(
- Message(
- "bad-whitespace",
- line=1,
- args=("Exactly one", "required", "before", "comparison", "a< b\n ^"),
- )
- ):
- self.checker.process_tokens(_tokenize_str("a< b\n"))
-
- with self.assertAddsMessages(
- Message(
- "bad-whitespace",
- line=1,
- args=("Exactly one", "required", "after", "comparison", "a <b\n ^"),
- )
- ):
- self.checker.process_tokens(_tokenize_str("a <b\n"))
-
- with self.assertAddsMessages(
- Message(
- "bad-whitespace",
- line=1,
- args=("Exactly one", "required", "around", "comparison", "a<b\n ^"),
- )
- ):
- self.checker.process_tokens(_tokenize_str("a<b\n"))
-
- with self.assertAddsMessages(
- Message(
- "bad-whitespace",
- line=1,
- args=("Exactly one", "required", "around", "comparison", "a< b\n ^"),
- )
- ):
- self.checker.process_tokens(_tokenize_str("a< b\n"))
-
- def testValidTypingAnnotationEllipses(self):
- """Make sure ellipses in function typing annotation
- doesn't cause a false positive bad-whitespace message"""
- with self.assertNoMessages():
- self.checker.process_tokens(
- _tokenize_str("def foo(t: Tuple[str, ...] = None):\n")
- )
-
def testEmptyLines(self):
self.checker.config.no_space_check = []
with self.assertAddsMessages(Message("trailing-whitespace", line=2)):
diff --git a/tests/functional/b/bad_whitespace.py b/tests/functional/b/bad_whitespace.py
deleted file mode 100644
index 9b32087e2..000000000
--- a/tests/functional/b/bad_whitespace.py
+++ /dev/null
@@ -1,7 +0,0 @@
-# pylint: disable = invalid-name,missing-docstring,unused-variable,unused-argument
-def function(hello):
- x, y, z = (1,2,3,) # [bad-whitespace, bad-whitespace]
-
-AAA =1 # [bad-whitespace]
-BBB = 2 # [bad-whitespace]
-CCC= 1 # [bad-whitespace]
diff --git a/tests/functional/b/bad_whitespace.txt b/tests/functional/b/bad_whitespace.txt
deleted file mode 100644
index 14431c04c..000000000
--- a/tests/functional/b/bad_whitespace.txt
+++ /dev/null
@@ -1,15 +0,0 @@
-bad-whitespace:3::"Exactly one space required after comma
- x, y, z = (1,2,3,) # [bad-whitespace, bad-whitespace]
- ^"
-bad-whitespace:3::"Exactly one space required after comma
- x, y, z = (1,2,3,) # [bad-whitespace, bad-whitespace]
- ^"
-bad-whitespace:5::"Exactly one space required after assignment
-AAA =1 # [bad-whitespace]
- ^"
-bad-whitespace:6::"Exactly one space required after assignment
-BBB = 2 # [bad-whitespace]
- ^"
-bad-whitespace:7::"Exactly one space required before assignment
-CCC= 1 # [bad-whitespace]
- ^"