Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move TestDocstringCheckerYield to functional tests #5435

Merged
merged 30 commits into from
Nov 29, 2021
Merged
Show file tree
Hide file tree
Changes from 29 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
514 changes: 0 additions & 514 deletions tests/extensions/test_check_yields_docs.py

This file was deleted.

12 changes: 12 additions & 0 deletions tests/functional/m/missing/yield/missing_yield_doc.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
"""Tests for missing-yield-doc and missing-yield-type-doc"""
# pylint: disable=missing-function-docstring, unused-argument, function-redefined

# Ignore no docstring
def my_func(self):
yield False


# Ignore unrecognized style docstring
def my_func(self):
"""This is a docstring."""
yield False
2 changes: 2 additions & 0 deletions tests/functional/m/missing/yield/missing_yield_doc.rc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[MASTER]
load-plugins = pylint.extensions.docparams
35 changes: 35 additions & 0 deletions tests/functional/m/missing/yield/missing_yield_doc_Google.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
"""Tests for missing-yield-doc and missing-yield-type-doc for Google style docstrings"""
# pylint: disable=missing-function-docstring, unused-argument, function-redefined
# pylint: disable=invalid-name, undefined-variable
import typing


# Test redudant yields docstring variants
def my_func(self):
"""This is a docstring.

Yields:
int or None: One, or sometimes None.
"""
if a_func():
yield None
yield 1


def my_func(self): # [redundant-yields-doc]
"""This is a docstring.

Yields:
int: One
"""
return 1


# Test missing yields typing docstring
def generator() -> typing.Iterator[int]:
"""A simple function for checking type hints.

Yields:
The number 0
"""
yield 0
2 changes: 2 additions & 0 deletions tests/functional/m/missing/yield/missing_yield_doc_Google.rc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[MASTER]
load-plugins = pylint.extensions.docparams
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
redundant-yields-doc:19:0:25:12:my_func:Redundant yields documentation:UNDEFINED
30 changes: 30 additions & 0 deletions tests/functional/m/missing/yield/missing_yield_doc_Numpy.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
"""Tests for missing-yield-doc and missing-yield-type-doc for Numpy style docstrings"""
# pylint: disable=missing-function-docstring, unused-argument, function-redefined
# pylint: disable=invalid-name, undefined-variable


# Test redudant yields docstring variants
def my_func(self):
"""This is a docstring.

Yields
-------
int
One
None
Sometimes
"""
if a_func():
yield None
yield 1


def my_func(self): # [redundant-yields-doc]
"""This is a docstring.

Yields
-------
int
One
"""
return 1
2 changes: 2 additions & 0 deletions tests/functional/m/missing/yield/missing_yield_doc_Numpy.rc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[MASTER]
load-plugins = pylint.extensions.docparams
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
redundant-yields-doc:22:0:30:12:my_func:Redundant yields documentation:UNDEFINED
13 changes: 13 additions & 0 deletions tests/functional/m/missing/yield/missing_yield_doc_Sphinx.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
"""Tests for missing-yield-doc and missing-yield-type-doc for Sphinx style docstrings"""
# pylint: disable=missing-function-docstring, unused-argument, function-redefined
# pylint: disable=invalid-name, undefined-variable
import typing


# Test missing yields typing docstring
def generator() -> typing.Iterator[int]:
"""A simple function for checking type hints.

:returns: The number 0
"""
yield 0
2 changes: 2 additions & 0 deletions tests/functional/m/missing/yield/missing_yield_doc_Sphinx.rc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[MASTER]
load-plugins = pylint.extensions.docparams
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
"""Tests for missing-yield-doc and missing-yield-type-doc with accept-no-yields-doc = no"""
# pylint: disable=missing-function-docstring, unused-argument, function-redefined


# Test missing docstring
def my_func(self): # [missing-yield-doc, missing-yield-type-doc]
yield False
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[MASTER]
load-plugins = pylint.extensions.docparams

[BASIC]
accept-no-yields-doc=no
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
missing-yield-doc:6:0:7:15:my_func:Missing yield documentation:UNDEFINED
missing-yield-type-doc:6:0:7:15:my_func:Missing yield type documentation:UNDEFINED
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
"""Tests for missing-yield-doc and missing-yield-type-doc for Google style docstrings
with accept-no-yields-doc = no"""
# pylint: disable=missing-function-docstring, unused-argument, function-redefined
# pylint: disable=invalid-name, undefined-variable


def my_func(self):
"""This is a docstring.

Yields:
bool: Always False
"""
yield False


def my_func(self):
"""This is a docstring.

Yields:
mymodule.Class: An object
"""
yield mymodule.Class()


def my_func(self):
"""This is a docstring.

Yields:
list(:class:`mymodule.Class`): An object
"""
yield [mymodule.Class()]


def my_func(self): # [missing-yield-doc]
"""This is a docstring.

Yields:
list(:class:`mymodule.Class`):
"""
yield [mymodule.Class()]


def my_func(self): # [missing-yield-type-doc]
"""This is a docstring.

Yields:
Always False
"""
yield False


def my_func(self): # [missing-yield-doc]
"""This is a docstring.

Yields:
bool:
"""
yield False


def my_func(self, doc_type): # [missing-yield-doc, missing-yield-type-doc]
"""This is a docstring.

Parameters:
doc_type (str): Google
"""
yield False
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[MASTER]
load-plugins = pylint.extensions.docparams

[BASIC]
accept-no-yields-doc=no
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
missing-yield-doc:34:0:40:28:my_func:Missing yield documentation:UNDEFINED
missing-yield-type-doc:43:0:49:15:my_func:Missing yield type documentation:UNDEFINED
missing-yield-doc:52:0:58:15:my_func:Missing yield documentation:UNDEFINED
missing-yield-doc:61:0:67:15:my_func:Missing yield documentation:UNDEFINED
missing-yield-type-doc:61:0:67:15:my_func:Missing yield type documentation:UNDEFINED
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
"""Tests for missing-yield-doc and missing-yield-type-doc for Numpy style docstrings
with accept-no-yields-doc = no"""
# pylint: disable=missing-function-docstring, unused-argument, function-redefined
# pylint: disable=invalid-name, undefined-variable


def my_func(self):
"""This is a docstring.

Yields
-------
bool
Always False
"""
yield False


def my_func(self):
"""This is a docstring.

Yields
-------
mymodule.Class
An object
"""
yield mymodule.Class()


def my_func(self):
"""This is a docstring.

Yields
-------
list(:class:`mymodule.Class`)
An object
"""
yield [mymodule.Class()]


def my_func(self): # [missing-yield-doc]
"""This is a docstring.

Yields
-------
list(:class:`mymodule.Class`)
"""
yield [mymodule.Class()]


def my_func(self, doc_type): # [missing-yield-doc, missing-yield-type-doc]
"""This is a docstring.

Arguments
---------
doc_type : str
Numpy
"""
yield False
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[MASTER]
load-plugins = pylint.extensions.docparams

[BASIC]
accept-no-yields-doc=no
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
missing-yield-doc:40:0:47:28:my_func:Missing yield documentation:UNDEFINED
missing-yield-doc:50:0:58:15:my_func:Missing yield documentation:UNDEFINED
missing-yield-type-doc:50:0:58:15:my_func:Missing yield type documentation:UNDEFINED
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
"""Tests for missing-yield-doc and missing-yield-type-doc for Sphinx style docstrings
with accept-no-yields-doc = no"""
# pylint: disable=missing-function-docstring, unused-argument, function-redefined
# pylint: disable=invalid-name, undefined-variable


# Test Sphinx docstring
def my_func(self):
"""This is a docstring.

:return: Always False
:rtype: bool
"""
yield False


def my_func(self):
"""This is a docstring.

:returns: An object
:rtype: :class:`mymodule.Class`
"""
yield mymodule.Class()


def my_func(self):
"""This is a docstring.

:returns: An object
:rtype: list(:class:`mymodule.Class`)
"""
yield [mymodule.Class()]


def my_func(self): # [missing-yield-doc]
"""This is a docstring.

:rtype: list(:class:`mymodule.Class`)
"""
yield [mymodule.Class()]


def my_func(self): # [missing-yield-type-doc]
"""This is a docstring.

:returns: Always False
"""
yield False


def my_func(self): # [missing-yield-doc]
"""This is a docstring.

:rtype: bool
"""
yield False


def my_func(self, doc_type): # [missing-yield-doc, missing-yield-type-doc]
"""This is a docstring.

:param doc_type: Sphinx
:type doc_type: str
"""
yield False
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[MASTER]
load-plugins = pylint.extensions.docparams

[BASIC]
accept-no-yields-doc=no
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
missing-yield-doc:35:0:40:28:my_func:Missing yield documentation:UNDEFINED
missing-yield-type-doc:43:0:48:15:my_func:Missing yield type documentation:UNDEFINED
missing-yield-doc:51:0:56:15:my_func:Missing yield documentation:UNDEFINED
missing-yield-doc:59:0:65:15:my_func:Missing yield documentation:UNDEFINED
missing-yield-type-doc:59:0:65:15:my_func:Missing yield type documentation:UNDEFINED