Skip to content

Commit f761b32

Browse files
authored
Move TestDocstringCheckerYield to functional tests (#5435)
1 parent 3652fae commit f761b32

23 files changed

+332
-514
lines changed

tests/extensions/test_check_yields_docs.py

Lines changed: 0 additions & 514 deletions
This file was deleted.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
"""Tests for missing-yield-doc and missing-yield-type-doc"""
2+
# pylint: disable=missing-function-docstring, unused-argument, function-redefined
3+
4+
# Ignore no docstring
5+
def my_func(self):
6+
yield False
7+
8+
9+
# Ignore unrecognized style docstring
10+
def my_func(self):
11+
"""This is a docstring."""
12+
yield False
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[MASTER]
2+
load-plugins = pylint.extensions.docparams
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
"""Tests for missing-yield-doc and missing-yield-type-doc for Google style docstrings"""
2+
# pylint: disable=missing-function-docstring, unused-argument, function-redefined
3+
# pylint: disable=invalid-name, undefined-variable
4+
import typing
5+
6+
7+
# Test redudant yields docstring variants
8+
def my_func(self):
9+
"""This is a docstring.
10+
11+
Yields:
12+
int or None: One, or sometimes None.
13+
"""
14+
if a_func():
15+
yield None
16+
yield 1
17+
18+
19+
def my_func(self): # [redundant-yields-doc]
20+
"""This is a docstring.
21+
22+
Yields:
23+
int: One
24+
"""
25+
return 1
26+
27+
28+
# Test missing yields typing docstring
29+
def generator() -> typing.Iterator[int]:
30+
"""A simple function for checking type hints.
31+
32+
Yields:
33+
The number 0
34+
"""
35+
yield 0
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[MASTER]
2+
load-plugins = pylint.extensions.docparams
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
redundant-yields-doc:19:0:25:12:my_func:Redundant yields documentation:UNDEFINED
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
"""Tests for missing-yield-doc and missing-yield-type-doc for Numpy style docstrings"""
2+
# pylint: disable=missing-function-docstring, unused-argument, function-redefined
3+
# pylint: disable=invalid-name, undefined-variable
4+
5+
6+
# Test redudant yields docstring variants
7+
def my_func(self):
8+
"""This is a docstring.
9+
10+
Yields
11+
-------
12+
int
13+
One
14+
None
15+
Sometimes
16+
"""
17+
if a_func():
18+
yield None
19+
yield 1
20+
21+
22+
def my_func(self): # [redundant-yields-doc]
23+
"""This is a docstring.
24+
25+
Yields
26+
-------
27+
int
28+
One
29+
"""
30+
return 1
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[MASTER]
2+
load-plugins = pylint.extensions.docparams
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
redundant-yields-doc:22:0:30:12:my_func:Redundant yields documentation:UNDEFINED
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
"""Tests for missing-yield-doc and missing-yield-type-doc for Sphinx style docstrings"""
2+
# pylint: disable=missing-function-docstring, unused-argument, function-redefined
3+
# pylint: disable=invalid-name, undefined-variable
4+
import typing
5+
6+
7+
# Test missing yields typing docstring
8+
def generator() -> typing.Iterator[int]:
9+
"""A simple function for checking type hints.
10+
11+
:returns: The number 0
12+
"""
13+
yield 0
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[MASTER]
2+
load-plugins = pylint.extensions.docparams
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
"""Tests for missing-yield-doc and missing-yield-type-doc with accept-no-yields-doc = no"""
2+
# pylint: disable=missing-function-docstring, unused-argument, function-redefined
3+
4+
5+
# Test missing docstring
6+
def my_func(self): # [missing-yield-doc, missing-yield-type-doc]
7+
yield False
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[MASTER]
2+
load-plugins = pylint.extensions.docparams
3+
4+
[BASIC]
5+
accept-no-yields-doc=no
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
missing-yield-doc:6:0:7:15:my_func:Missing yield documentation:UNDEFINED
2+
missing-yield-type-doc:6:0:7:15:my_func:Missing yield type documentation:UNDEFINED
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
"""Tests for missing-yield-doc and missing-yield-type-doc for Google style docstrings
2+
with accept-no-yields-doc = no"""
3+
# pylint: disable=missing-function-docstring, unused-argument, function-redefined
4+
# pylint: disable=invalid-name, undefined-variable
5+
6+
7+
def my_func(self):
8+
"""This is a docstring.
9+
10+
Yields:
11+
bool: Always False
12+
"""
13+
yield False
14+
15+
16+
def my_func(self):
17+
"""This is a docstring.
18+
19+
Yields:
20+
mymodule.Class: An object
21+
"""
22+
yield mymodule.Class()
23+
24+
25+
def my_func(self):
26+
"""This is a docstring.
27+
28+
Yields:
29+
list(:class:`mymodule.Class`): An object
30+
"""
31+
yield [mymodule.Class()]
32+
33+
34+
def my_func(self): # [missing-yield-doc]
35+
"""This is a docstring.
36+
37+
Yields:
38+
list(:class:`mymodule.Class`):
39+
"""
40+
yield [mymodule.Class()]
41+
42+
43+
def my_func(self): # [missing-yield-type-doc]
44+
"""This is a docstring.
45+
46+
Yields:
47+
Always False
48+
"""
49+
yield False
50+
51+
52+
def my_func(self): # [missing-yield-doc]
53+
"""This is a docstring.
54+
55+
Yields:
56+
bool:
57+
"""
58+
yield False
59+
60+
61+
def my_func(self, doc_type): # [missing-yield-doc, missing-yield-type-doc]
62+
"""This is a docstring.
63+
64+
Parameters:
65+
doc_type (str): Google
66+
"""
67+
yield False
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[MASTER]
2+
load-plugins = pylint.extensions.docparams
3+
4+
[BASIC]
5+
accept-no-yields-doc=no
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
missing-yield-doc:34:0:40:28:my_func:Missing yield documentation:UNDEFINED
2+
missing-yield-type-doc:43:0:49:15:my_func:Missing yield type documentation:UNDEFINED
3+
missing-yield-doc:52:0:58:15:my_func:Missing yield documentation:UNDEFINED
4+
missing-yield-doc:61:0:67:15:my_func:Missing yield documentation:UNDEFINED
5+
missing-yield-type-doc:61:0:67:15:my_func:Missing yield type documentation:UNDEFINED
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
"""Tests for missing-yield-doc and missing-yield-type-doc for Numpy style docstrings
2+
with accept-no-yields-doc = no"""
3+
# pylint: disable=missing-function-docstring, unused-argument, function-redefined
4+
# pylint: disable=invalid-name, undefined-variable
5+
6+
7+
def my_func(self):
8+
"""This is a docstring.
9+
10+
Yields
11+
-------
12+
bool
13+
Always False
14+
"""
15+
yield False
16+
17+
18+
def my_func(self):
19+
"""This is a docstring.
20+
21+
Yields
22+
-------
23+
mymodule.Class
24+
An object
25+
"""
26+
yield mymodule.Class()
27+
28+
29+
def my_func(self):
30+
"""This is a docstring.
31+
32+
Yields
33+
-------
34+
list(:class:`mymodule.Class`)
35+
An object
36+
"""
37+
yield [mymodule.Class()]
38+
39+
40+
def my_func(self): # [missing-yield-doc]
41+
"""This is a docstring.
42+
43+
Yields
44+
-------
45+
list(:class:`mymodule.Class`)
46+
"""
47+
yield [mymodule.Class()]
48+
49+
50+
def my_func(self, doc_type): # [missing-yield-doc, missing-yield-type-doc]
51+
"""This is a docstring.
52+
53+
Arguments
54+
---------
55+
doc_type : str
56+
Numpy
57+
"""
58+
yield False
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[MASTER]
2+
load-plugins = pylint.extensions.docparams
3+
4+
[BASIC]
5+
accept-no-yields-doc=no
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
missing-yield-doc:40:0:47:28:my_func:Missing yield documentation:UNDEFINED
2+
missing-yield-doc:50:0:58:15:my_func:Missing yield documentation:UNDEFINED
3+
missing-yield-type-doc:50:0:58:15:my_func:Missing yield type documentation:UNDEFINED
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
"""Tests for missing-yield-doc and missing-yield-type-doc for Sphinx style docstrings
2+
with accept-no-yields-doc = no"""
3+
# pylint: disable=missing-function-docstring, unused-argument, function-redefined
4+
# pylint: disable=invalid-name, undefined-variable
5+
6+
7+
# Test Sphinx docstring
8+
def my_func(self):
9+
"""This is a docstring.
10+
11+
:return: Always False
12+
:rtype: bool
13+
"""
14+
yield False
15+
16+
17+
def my_func(self):
18+
"""This is a docstring.
19+
20+
:returns: An object
21+
:rtype: :class:`mymodule.Class`
22+
"""
23+
yield mymodule.Class()
24+
25+
26+
def my_func(self):
27+
"""This is a docstring.
28+
29+
:returns: An object
30+
:rtype: list(:class:`mymodule.Class`)
31+
"""
32+
yield [mymodule.Class()]
33+
34+
35+
def my_func(self): # [missing-yield-doc]
36+
"""This is a docstring.
37+
38+
:rtype: list(:class:`mymodule.Class`)
39+
"""
40+
yield [mymodule.Class()]
41+
42+
43+
def my_func(self): # [missing-yield-type-doc]
44+
"""This is a docstring.
45+
46+
:returns: Always False
47+
"""
48+
yield False
49+
50+
51+
def my_func(self): # [missing-yield-doc]
52+
"""This is a docstring.
53+
54+
:rtype: bool
55+
"""
56+
yield False
57+
58+
59+
def my_func(self, doc_type): # [missing-yield-doc, missing-yield-type-doc]
60+
"""This is a docstring.
61+
62+
:param doc_type: Sphinx
63+
:type doc_type: str
64+
"""
65+
yield False
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[MASTER]
2+
load-plugins = pylint.extensions.docparams
3+
4+
[BASIC]
5+
accept-no-yields-doc=no
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
missing-yield-doc:35:0:40:28:my_func:Missing yield documentation:UNDEFINED
2+
missing-yield-type-doc:43:0:48:15:my_func:Missing yield type documentation:UNDEFINED
3+
missing-yield-doc:51:0:56:15:my_func:Missing yield documentation:UNDEFINED
4+
missing-yield-doc:59:0:65:15:my_func:Missing yield documentation:UNDEFINED
5+
missing-yield-type-doc:59:0:65:15:my_func:Missing yield type documentation:UNDEFINED

0 commit comments

Comments
 (0)