summaryrefslogtreecommitdiff
path: root/tests/functional/e
diff options
context:
space:
mode:
authorPierre Sassoulas <pierre.sassoulas@gmail.com>2021-11-22 15:21:27 +0100
committerPierre Sassoulas <pierre.sassoulas@gmail.com>2021-11-22 23:08:30 +0100
commit14f7b7cfcdeab557ee84478eb39654e029c90bfe (patch)
tree79a3be1d8c224162c3fb832ca36bf4dbeaa6b4ec /tests/functional/e
parent9e32192fe7bf77281d0dfbc107984b751983e113 (diff)
downloadpylint-git-14f7b7cfcdeab557ee84478eb39654e029c90bfe.tar.gz
Migrate test for extension to functional testsmigrate-extension-tests-to-functional
This permit to upgrade the fixtures in pre-commit.
Diffstat (limited to 'tests/functional/e')
-rw-r--r--tests/functional/e/elif_checker.py27
-rw-r--r--tests/functional/e/elif_checker.rc2
-rw-r--r--tests/functional/e/elif_checker.txt2
-rw-r--r--tests/functional/e/empty_comment.py13
-rw-r--r--tests/functional/e/empty_comment.rc2
-rw-r--r--tests/functional/e/empty_comment.txt4
-rw-r--r--tests/functional/e/empty_string_comparison.py16
-rw-r--r--tests/functional/e/empty_string_comparison.rc2
-rw-r--r--tests/functional/e/empty_string_comparison.txt4
9 files changed, 72 insertions, 0 deletions
diff --git a/tests/functional/e/elif_checker.py b/tests/functional/e/elif_checker.py
new file mode 100644
index 000000000..b9722f349
--- /dev/null
+++ b/tests/functional/e/elif_checker.py
@@ -0,0 +1,27 @@
+"""Checks use of "else if" triggers a refactor message"""
+
+
+def my_function():
+ """docstring"""
+ myint = 2
+ if myint > 5:
+ pass
+ else:
+ if myint <= 5: # [else-if-used]
+ pass
+ else:
+ myint = 3
+ if myint > 2:
+ if myint > 3:
+ pass
+ elif myint == 3:
+ pass
+ elif myint < 3:
+ pass
+ else:
+ if myint: # [else-if-used]
+ pass
+ else:
+ if myint:
+ pass
+ myint = 4
diff --git a/tests/functional/e/elif_checker.rc b/tests/functional/e/elif_checker.rc
new file mode 100644
index 000000000..b9b1de49d
--- /dev/null
+++ b/tests/functional/e/elif_checker.rc
@@ -0,0 +1,2 @@
+[MASTER]
+load-plugins=pylint.extensions.check_elif,
diff --git a/tests/functional/e/elif_checker.txt b/tests/functional/e/elif_checker.txt
new file mode 100644
index 000000000..43d1e3b1e
--- /dev/null
+++ b/tests/functional/e/elif_checker.txt
@@ -0,0 +1,2 @@
+else-if-used:10:8:my_function:"Consider using ""elif"" instead of ""else if""":HIGH
+else-if-used:22:20:my_function:"Consider using ""elif"" instead of ""else if""":HIGH
diff --git a/tests/functional/e/empty_comment.py b/tests/functional/e/empty_comment.py
new file mode 100644
index 000000000..6adaa4fc1
--- /dev/null
+++ b/tests/functional/e/empty_comment.py
@@ -0,0 +1,13 @@
+"""empty-comment test-case"""
+# +1:[empty-comment]
+A = 5 #
+# +1:[empty-comment]
+#
+A = '#' + '1'
+# +1:[empty-comment]
+print(A) #
+print("A=", A) # should not be an error#
+# +1:[empty-comment]
+A = "#pe\0ace#love#" #
+A = "peace#love" # \0 peace'#'''' love#peace'''-'#love'-"peace#love"#
+#######
diff --git a/tests/functional/e/empty_comment.rc b/tests/functional/e/empty_comment.rc
new file mode 100644
index 000000000..1bbd021e7
--- /dev/null
+++ b/tests/functional/e/empty_comment.rc
@@ -0,0 +1,2 @@
+[MASTER]
+load-plugins=pylint.extensions.empty_comment,
diff --git a/tests/functional/e/empty_comment.txt b/tests/functional/e/empty_comment.txt
new file mode 100644
index 000000000..ae4eee33e
--- /dev/null
+++ b/tests/functional/e/empty_comment.txt
@@ -0,0 +1,4 @@
+empty-comment:3:0::Line with empty comment:HIGH
+empty-comment:5:0::Line with empty comment:HIGH
+empty-comment:8:0::Line with empty comment:HIGH
+empty-comment:11:0::Line with empty comment:HIGH
diff --git a/tests/functional/e/empty_string_comparison.py b/tests/functional/e/empty_string_comparison.py
new file mode 100644
index 000000000..c6dcf8ea8
--- /dev/null
+++ b/tests/functional/e/empty_string_comparison.py
@@ -0,0 +1,16 @@
+# pylint: disable=literal-comparison,missing-docstring
+
+X = ''
+Y = 'test'
+
+if X is '': # [compare-to-empty-string]
+ pass
+
+if Y is not "": # [compare-to-empty-string]
+ pass
+
+if X == "": # [compare-to-empty-string]
+ pass
+
+if Y != '': # [compare-to-empty-string]
+ pass
diff --git a/tests/functional/e/empty_string_comparison.rc b/tests/functional/e/empty_string_comparison.rc
new file mode 100644
index 000000000..e6e3ded01
--- /dev/null
+++ b/tests/functional/e/empty_string_comparison.rc
@@ -0,0 +1,2 @@
+[MASTER]
+load-plugins=pylint.extensions.emptystring,
diff --git a/tests/functional/e/empty_string_comparison.txt b/tests/functional/e/empty_string_comparison.txt
new file mode 100644
index 000000000..7e31c3d25
--- /dev/null
+++ b/tests/functional/e/empty_string_comparison.txt
@@ -0,0 +1,4 @@
+compare-to-empty-string:6:3::Avoid comparisons to empty string:HIGH
+compare-to-empty-string:9:3::Avoid comparisons to empty string:HIGH
+compare-to-empty-string:12:3::Avoid comparisons to empty string:HIGH
+compare-to-empty-string:15:3::Avoid comparisons to empty string:HIGH