summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniël van Noord <13665637+DanielNoord@users.noreply.github.com>2021-11-30 10:10:22 +0100
committerGitHub <noreply@github.com>2021-11-30 10:10:22 +0100
commit582494b08675c1fc7b9098ff231e848e1786c968 (patch)
tree8f349a9593e39e424b0bb061668588d829f6d1dc
parentc278e058c51ea633c0a2761a48410b392cf10e82 (diff)
downloadpylint-git-582494b08675c1fc7b9098ff231e848e1786c968.tar.gz
Move ``TestDocstringCheckerRaise`` to functional tests (#5444)
-rw-r--r--tests/extensions/test_check_raise_docs.py902
-rw-r--r--tests/functional/ext/docparams/raise/missing_raises_doc.py98
-rw-r--r--tests/functional/ext/docparams/raise/missing_raises_doc.rc2
-rw-r--r--tests/functional/ext/docparams/raise/missing_raises_doc.txt4
-rw-r--r--tests/functional/ext/docparams/raise/missing_raises_doc_Google.py138
-rw-r--r--tests/functional/ext/docparams/raise/missing_raises_doc_Google.rc2
-rw-r--r--tests/functional/ext/docparams/raise/missing_raises_doc_Google.txt9
-rw-r--r--tests/functional/ext/docparams/raise/missing_raises_doc_Numpy.py131
-rw-r--r--tests/functional/ext/docparams/raise/missing_raises_doc_Numpy.rc2
-rw-r--r--tests/functional/ext/docparams/raise/missing_raises_doc_Numpy.txt6
-rw-r--r--tests/functional/ext/docparams/raise/missing_raises_doc_Sphinx.py151
-rw-r--r--tests/functional/ext/docparams/raise/missing_raises_doc_Sphinx.rc2
-rw-r--r--tests/functional/ext/docparams/raise/missing_raises_doc_Sphinx.txt13
-rw-r--r--tests/functional/ext/docparams/raise/missing_raises_doc_required.py8
-rw-r--r--tests/functional/ext/docparams/raise/missing_raises_doc_required.rc5
-rw-r--r--tests/functional/ext/docparams/raise/missing_raises_doc_required.txt1
-rw-r--r--tests/functional/ext/docparams/raise/missing_raises_doc_required_Google.py26
-rw-r--r--tests/functional/ext/docparams/raise/missing_raises_doc_required_Google.rc5
-rw-r--r--tests/functional/ext/docparams/raise/missing_raises_doc_required_Numpy.py30
-rw-r--r--tests/functional/ext/docparams/raise/missing_raises_doc_required_Numpy.rc5
-rw-r--r--tests/functional/ext/docparams/raise/missing_raises_doc_required_Sphinx.py24
-rw-r--r--tests/functional/ext/docparams/raise/missing_raises_doc_required_Sphinx.rc5
22 files changed, 667 insertions, 902 deletions
diff --git a/tests/extensions/test_check_raise_docs.py b/tests/extensions/test_check_raise_docs.py
deleted file mode 100644
index f191bc14e..000000000
--- a/tests/extensions/test_check_raise_docs.py
+++ /dev/null
@@ -1,902 +0,0 @@
-# Copyright (c) 2016-2018, 2020 Claudiu Popa <pcmanticore@gmail.com>
-# Copyright (c) 2016, 2019 Ashley Whetter <ashley@awhetter.co.uk>
-# Copyright (c) 2016 Derek Gustafson <degustaf@gmail.com>
-# Copyright (c) 2016 Glenn Matthews <glenn@e-dad.net>
-# Copyright (c) 2018 Jim Robertson <jrobertson98atx@gmail.com>
-# Copyright (c) 2018 Adam Dangoor <adamdangoor@gmail.com>
-# Copyright (c) 2019-2021 Pierre Sassoulas <pierre.sassoulas@gmail.com>
-# Copyright (c) 2019 Hugo van Kemenade <hugovk@users.noreply.github.com>
-# Copyright (c) 2019 Danny Hermes <daniel.j.hermes@gmail.com>
-# Copyright (c) 2020 hippo91 <guillaume.peillex@gmail.com>
-# Copyright (c) 2021 Daniël van Noord <13665637+DanielNoord@users.noreply.github.com>
-# Copyright (c) 2021 Marc Mueller <30130371+cdce8p@users.noreply.github.com>
-
-# Licensed under the GPL: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
-# For details: https://github.com/PyCQA/pylint/blob/main/LICENSE
-
-"""Unit tests for the raised exception documentation checking in the
-`DocstringChecker` in :mod:`pylint.extensions.check_docs`
-"""
-
-# pylint: disable=too-many-public-methods
-
-import astroid
-
-from pylint.extensions.docparams import DocstringParameterChecker
-from pylint.testutils import CheckerTestCase, MessageTest, set_config
-
-
-class TestDocstringCheckerRaise(CheckerTestCase):
- """Tests for pylint_plugin.RaiseDocChecker"""
-
- CHECKER_CLASS = DocstringParameterChecker
-
- def test_ignores_no_docstring(self) -> None:
- raise_node = astroid.extract_node(
- """
- def my_func(self):
- raise RuntimeError('hi') #@
- """
- )
- with self.assertNoMessages():
- self.checker.visit_raise(raise_node)
-
- def test_ignores_unknown_style(self) -> None:
- node = astroid.extract_node(
- '''
- def my_func(self):
- """This is a docstring."""
- raise RuntimeError('hi')
- '''
- )
- raise_node = node.body[0]
- with self.assertNoMessages():
- self.checker.visit_raise(raise_node)
-
- @set_config(accept_no_raise_doc=False)
- def test_warns_unknown_style(self) -> None:
- node = astroid.extract_node(
- '''
- def my_func(self):
- """This is a docstring."""
- raise RuntimeError('hi')
- '''
- )
- raise_node = node.body[0]
- with self.assertAddsMessages(
- MessageTest(msg_id="missing-raises-doc", node=node, args=("RuntimeError",))
- ):
- self.checker.visit_raise(raise_node)
-
- def test_find_missing_sphinx_raises(self) -> None:
- node = astroid.extract_node(
- '''
- def my_func(self):
- """This is a docstring.
-
- :raises NameError: Never
- """
- raise RuntimeError('hi')
- raise NameError('hi')
- '''
- )
- raise_node = node.body[0]
- with self.assertAddsMessages(
- MessageTest(msg_id="missing-raises-doc", node=node, args=("RuntimeError",))
- ):
- self.checker.visit_raise(raise_node)
-
- def test_find_missing_google_raises(self) -> None:
- node = astroid.extract_node(
- '''
- def my_func(self):
- """This is a docstring.
-
- Raises:
- NameError: Never
- """
- raise RuntimeError('hi')
- raise NameError('hi')
- '''
- )
- raise_node = node.body[0]
- with self.assertAddsMessages(
- MessageTest(msg_id="missing-raises-doc", node=node, args=("RuntimeError",))
- ):
- self.checker.visit_raise(raise_node)
-
- def test_find_google_attr_raises_exact_exc(self) -> None:
- raise_node = astroid.extract_node(
- '''
- def my_func(self):
- """This is a google docstring.
-
- Raises:
- re.error: Sometimes
- """
- import re
- raise re.error('hi') #@
- '''
- )
- with self.assertNoMessages():
- self.checker.visit_raise(raise_node)
-
- def test_find_google_attr_raises_substr_exc(self) -> None:
- raise_node = astroid.extract_node(
- '''
- def my_func(self):
- """This is a google docstring.
-
- Raises:
- re.error: Sometimes
- """
- from re import error
- raise error('hi') #@
- '''
- )
- with self.assertNoMessages():
- self.checker.visit_raise(raise_node)
-
- def test_find_valid_missing_google_attr_raises(self) -> None:
- node = astroid.extract_node(
- '''
- def my_func(self):
- """This is a google docstring.
-
- Raises:
- re.anothererror: Sometimes
- """
- from re import error
- raise error('hi')
- '''
- )
- raise_node = node.body[1]
- with self.assertAddsMessages(
- MessageTest(msg_id="missing-raises-doc", node=node, args=("error",))
- ):
- self.checker.visit_raise(raise_node)
-
- def test_find_invalid_missing_google_attr_raises(self) -> None:
- raise_node = astroid.extract_node(
- '''
- def my_func(self):
- """This is a google docstring.
-
- Raises:
- bogusmodule.error: Sometimes
- """
- from re import error
- raise error('hi') #@
- '''
- )
- # pylint allows this to pass since the comparison between Raises and
- # raise are based on the class name, not the qualified name.
- with self.assertNoMessages():
- self.checker.visit_raise(raise_node)
-
- def test_google_raises_local_reference(self) -> None:
- raise_node = astroid.extract_node(
- '''
- def my_func(self):
- """This is a google docstring.
-
- Raises:
- .LocalException: Always
- """
- from neighbor_module import LocalException
- raise LocalException('hi') #@
- '''
- )
- # pylint allows this to pass since the comparison between Raises and
- # raise are based on the class name, not the qualified name.
- with self.assertNoMessages():
- self.checker.visit_raise(raise_node)
-
- @set_config(accept_no_raise_doc=False)
- def test_google_raises_with_prefix(self) -> None:
- code_snippet = '''
- def my_func(self):
- """This is a google docstring.
-
- Raises:
- {prefix}re.error: Sometimes
- """
- import re
- raise re.error('hi') #@
- '''
- for prefix in ("~", "!"):
- raise_node = astroid.extract_node(code_snippet.format(prefix=prefix))
- with self.assertNoMessages():
- self.checker.visit_raise(raise_node)
-
- def test_find_missing_numpy_raises(self) -> None:
- node = astroid.extract_node(
- '''
- def my_func(self):
- """This is a docstring.
-
- Raises
- ------
- NameError
- Never
- """
- raise RuntimeError('hi')
- raise NameError('hi')
- '''
- )
- raise_node = node.body[0]
- with self.assertAddsMessages(
- MessageTest(msg_id="missing-raises-doc", node=node, args=("RuntimeError",))
- ):
- self.checker.visit_raise(raise_node)
-
- def test_ignore_spurious_sphinx_raises(self) -> None:
- raise_node = astroid.extract_node(
- '''
- def my_func(self):
- """This is a docstring.
-
- :raises RuntimeError: Always
- :except NameError: Never
- :raise OSError: Never
- :exception ValueError: Never
- """
- raise RuntimeError('Blah') #@
- '''
- )
- with self.assertNoMessages():
- self.checker.visit_raise(raise_node)
-
- def test_find_all_sphinx_raises(self) -> None:
- raise_node = astroid.extract_node(
- '''
- def my_func(self):
- """This is a docstring.
-
- :raises RuntimeError: Always
- :except NameError: Never
- :raise OSError: Never
- :exception ValueError: Never
- """
- raise RuntimeError('hi') #@
- raise NameError('hi')
- raise OSError(2, 'abort!')
- raise ValueError('foo')
- '''
- )
- with self.assertNoMessages():
- self.checker.visit_raise(raise_node)
-
- def test_find_all_google_raises(self) -> None:
- raise_node = astroid.extract_node(
- '''
- def my_func(self):
- """This is a docstring.
-
- Raises:
- RuntimeError: Always
- NameError: Never
- """
- raise RuntimeError('hi') #@
- raise NameError('hi')
- '''
- )
- with self.assertNoMessages():
- self.checker.visit_raise(raise_node)
-
- def test_find_all_numpy_raises(self) -> None:
- raise_node = astroid.extract_node(
- '''
- def my_func(self):
- """This is a docstring.
-
- Raises
- ------
- RuntimeError
- Always
- NameError
- Never
- """
- raise RuntimeError('hi') #@
- raise NameError('hi')
- '''
- )
- with self.assertNoMessages():
- self.checker.visit_raise(raise_node)
-
- def test_find_multiple_sphinx_raises(self) -> None:
- raise_node = astroid.extract_node(
- '''
- def my_func(self):
- """This is a docstring.
-
- :raises RuntimeError: Always
- :raises NameError, OSError, ValueError: Never
- """
- raise RuntimeError('hi')
- raise NameError('hi') #@
- raise OSError(2, 'abort!')
- raise ValueError('foo')
- '''
- )
- with self.assertNoMessages():
- self.checker.visit_raise(raise_node)
-
- def test_find_multiple_google_raises(self) -> None:
- raise_node = astroid.extract_node(
- '''
- def my_func(self):
- """This is a docstring.
-
- Raises:
- RuntimeError: Always
- NameError, OSError, ValueError: Never
- """
- raise RuntimeError('hi')
- raise NameError('hi') #@
- raise OSError(2, 'abort!')
- raise ValueError('foo')
- '''
- )
- with self.assertNoMessages():
- self.checker.visit_raise(raise_node)
-
- def test_finds_rethrown_sphinx_raises(self) -> None:
- raise_node = astroid.extract_node(
- '''
- def my_func(self):
- """This is a docstring.
-
- :raises NameError: Sometimes
- """
- try:
- fake_func()
- except RuntimeError:
- raise #@
-
- raise NameError('hi')
- '''
- )
- node = raise_node.frame()
- with self.assertAddsMessages(
- MessageTest(msg_id="missing-raises-doc", node=node, args=("RuntimeError",))
- ):
- self.checker.visit_raise(raise_node)
-
- def test_find_rethrown_google_raises(self) -> None:
- raise_node = astroid.extract_node(
- '''
- def my_func(self):
- """This is a docstring.
-
- Raises:
- NameError: Sometimes
- """
- try:
- fake_func()
- except RuntimeError:
- raise #@
-
- raise NameError('hi')
- '''
- )
- node = raise_node.frame()
- with self.assertAddsMessages(
- MessageTest(msg_id="missing-raises-doc", node=node, args=("RuntimeError",))
- ):
- self.checker.visit_raise(raise_node)
-
- def test_find_rethrown_numpy_raises(self) -> None:
- raise_node = astroid.extract_node(
- '''
- def my_func(self):
- """This is a docstring.
-
- Raises
- ------
- NameError
- Sometimes
- """
- try:
- fake_func()
- except RuntimeError:
- raise #@
-
- raise NameError('hi')
- '''
- )
- node = raise_node.frame()
- with self.assertAddsMessages(
- MessageTest(msg_id="missing-raises-doc", node=node, args=("RuntimeError",))
- ):
- self.checker.visit_raise(raise_node)
-
- def test_finds_rethrown_sphinx_multiple_raises(self) -> None:
- raise_node = astroid.extract_node(
- '''
- def my_func(self):
- """This is a docstring.
-
- :raises NameError: Sometimes
- """
- try:
- fake_func()
- except (RuntimeError, ValueError):
- raise #@
-
- raise NameError('hi')
- '''
- )
- node = raise_node.frame()
- with self.assertAddsMessages(
- MessageTest(
- msg_id="missing-raises-doc",
- node=node,
- args=("RuntimeError, ValueError",),
- )
- ):
- self.checker.visit_raise(raise_node)
-
- def test_find_rethrown_google_multiple_raises(self) -> None:
- raise_node = astroid.extract_node(
- '''
- def my_func(self):
- """This is a docstring.
-
- Raises:
- NameError: Sometimes
- """
- try:
- fake_func()
- except (RuntimeError, ValueError):
- raise #@
-
- raise NameError('hi')
- '''
- )
- node = raise_node.frame()
- with self.assertAddsMessages(
- MessageTest(
- msg_id="missing-raises-doc",
- node=node,
- args=("RuntimeError, ValueError",),
- )
- ):
- self.checker.visit_raise(raise_node)
-
- def test_find_rethrown_numpy_multiple_raises(self) -> None:
- raise_node = astroid.extract_node(
- '''
- def my_func(self):
- """This is a docstring.
-
- Raises
- ------
- NameError
- Sometimes
- """
- try:
- fake_func()
- except (RuntimeError, ValueError):
- raise #@
-
- raise NameError('hi')
- '''
- )
- node = raise_node.frame()
- with self.assertAddsMessages(
- MessageTest(
- msg_id="missing-raises-doc",
- node=node,
- args=("RuntimeError, ValueError",),
- )
- ):
- self.checker.visit_raise(raise_node)
-
- def test_ignores_caught_sphinx_raises(self) -> None:
- raise_node = astroid.extract_node(
- '''
- def my_func(self):
- """This is a docstring.
-
- :raises NameError: Sometimes
- """
- try:
- raise RuntimeError('hi') #@
- except RuntimeError:
- pass
-
- raise NameError('hi')
- '''
- )
- with self.assertNoMessages():
- self.checker.visit_raise(raise_node)
-
- def test_ignores_caught_google_raises(self) -> None:
- raise_node = astroid.extract_node(
- '''
- def my_func(self):
- """This is a docstring.
-
- Raises:
- NameError: Sometimes
- """
- try:
- raise RuntimeError('hi') #@
- except RuntimeError:
- pass
-
- raise NameError('hi')
- '''
- )
- with self.assertNoMessages():
- self.checker.visit_raise(raise_node)
-
- def test_ignores_caught_numpy_raises(self) -> None:
- raise_node = astroid.extract_node(
- '''
- def my_func(self):
- """This is a numpy docstring.
-
- Raises
- ------
- NameError
- Sometimes
- """
- try:
- raise RuntimeError('hi') #@
- except RuntimeError:
- pass
-
- raise NameError('hi')
- '''
- )
- with self.assertNoMessages():
- self.checker.visit_raise(raise_node)
-
- def test_find_numpy_attr_raises_exact_exc(self) -> None:
- raise_node = astroid.extract_node(
- '''
- def my_func(self):
- """This is a numpy docstring.
-
- Raises
- ------
- re.error
- Sometimes
- """
- import re
- raise re.error('hi') #@
- '''
- )
- with self.assertNoMessages():
- self.checker.visit_raise(raise_node)
-
- def test_find_numpy_attr_raises_substr_exc(self) -> None:
- raise_node = astroid.extract_node(
- '''
- def my_func(self):
- """This is a numpy docstring.
-
- Raises
- ------
- re.error
- Sometimes
- """
- from re import error
- raise error('hi') #@
- '''
- )
- with self.assertNoMessages():
- self.checker.visit_raise(raise_node)
-
- def test_find_valid_missing_numpy_attr_raises(self) -> None:
- node = astroid.extract_node(
- '''
- def my_func(self):
- """This is a numpy docstring.
-
- Raises
- ------
- re.anothererror
- Sometimes
- """
- from re import error
- raise error('hi')
- '''
- )
- raise_node = node.body[1]
- with self.assertAddsMessages(
- MessageTest(msg_id="missing-raises-doc", node=node, args=("error",))
- ):
- self.checker.visit_raise(raise_node)
-
- def test_find_invalid_missing_numpy_attr_raises(self) -> None:
- raise_node = astroid.extract_node(
- '''
- def my_func(self):
- """This is a numpy docstring.
-
- Raises
- ------
- bogusmodule.error
- Sometimes
- """
- from re import error
- raise error('hi') #@
- '''
- )
- # pylint allows this to pass since the comparison between Raises and
- # raise are based on the class name, not the qualified name.
- with self.assertNoMessages():
- self.checker.visit_raise(raise_node)
-
- @set_config(accept_no_raise_doc=False)
- def test_numpy_raises_with_prefix(self) -> None:
- code_snippet = '''
- def my_func(self):
- """This is a numpy docstring.
-
- Raises
- ------
- {prefix}re.error
- Sometimes
- """
- import re
- raise re.error('hi') #@
- '''
- for prefix in ("~", "!"):
- raise_node = astroid.extract_node(code_snippet.format(prefix=prefix))
- with self.assertNoMessages():
- self.checker.visit_raise(raise_node)
-
- def test_find_missing_sphinx_raises_infer_from_instance(self) -> None:
- raise_node = astroid.extract_node(
- '''
- def my_func(self):
- """This is a docstring.
-
- :raises NameError: Never
- """
- my_exception = RuntimeError('hi')
- raise my_exception #@
- raise NameError('hi')
- '''
- )
- node = raise_node.frame()
- with self.assertAddsMessages(
- MessageTest(msg_id="missing-raises-doc", node=node, args=("RuntimeError",))
- ):
- self.checker.visit_raise(raise_node)
-
- def test_find_missing_sphinx_raises_infer_from_function(self) -> None:
- raise_node = astroid.extract_node(
- '''
- def my_func(self):
- """This is a docstring.
-
- :raises NameError: Never
- """
- def ex_func(val):
- return RuntimeError(val)
- raise ex_func('hi') #@
- raise NameError('hi')
- '''
- )
- node = raise_node.frame()
- with self.assertAddsMessages(
- MessageTest(msg_id="missing-raises-doc", node=node, args=("RuntimeError",))
- ):
- self.checker.visit_raise(raise_node)
-
- def test_find_sphinx_attr_raises_exact_exc(self) -> None:
- raise_node = astroid.extract_node(
- '''
- def my_func(self):
- """This is a sphinx docstring.
-
- :raises re.error: Sometimes
- """
- import re
- raise re.error('hi') #@
- '''
- )
- with self.assertNoMessages():
- self.checker.visit_raise(raise_node)
-
- def test_find_sphinx_attr_raises_substr_exc(self) -> None:
- raise_node = astroid.extract_node(
- '''
- def my_func(self):
- """This is a sphinx docstring.
-
- :raises re.error: Sometimes
- """
- from re import error
- raise error('hi') #@
- '''
- )
- with self.assertNoMessages():
- self.checker.visit_raise(raise_node)
-
- def test_find_valid_missing_sphinx_attr_raises(self) -> None:
- node = astroid.extract_node(
- '''
- def my_func(self):
- """This is a sphinx docstring.
-
- :raises re.anothererror: Sometimes
- """
- from re import error
- raise error('hi')
- '''
- )
- raise_node = node.body[1]
- with self.assertAddsMessages(
- MessageTest(msg_id="missing-raises-doc", node=node, args=("error",))
- ):
- self.checker.visit_raise(raise_node)
-
- def test_find_invalid_missing_sphinx_attr_raises(self) -> None:
- raise_node = astroid.extract_node(
- '''
- def my_func(self):
- """This is a sphinx docstring.
-
- :raises bogusmodule.error: Sometimes
- """
- from re import error
- raise error('hi') #@
- '''
- )
- # pylint allows this to pass since the comparison between Raises and
- # raise are based on the class name, not the qualified name.
- with self.assertNoMessages():
- self.checker.visit_raise(raise_node)
-
- @set_config(accept_no_raise_doc=False)
- def test_sphinx_raises_with_prefix(self) -> None:
- code_snippet = '''
- def my_func(self):
- """This is a sphinx docstring.
-
- :raises {prefix}re.error: Sometimes
- """
- import re
- raise re.error('hi') #@
- '''
- for prefix in ("~", "!"):
- raise_node = astroid.extract_node(code_snippet.format(prefix=prefix))
- with self.assertNoMessages():
- self.checker.visit_raise(raise_node)
-
- with self.assertNoMessages():
- self.checker.visit_raise(raise_node)
-
- def test_ignores_raise_uninferable(self) -> None:
- raise_node = astroid.extract_node(
- '''
- from unknown import Unknown
-
- def my_func(self):
- """This is a docstring.
-
- :raises NameError: Never
- """
- raise Unknown('hi') #@
- raise NameError('hi')
- '''
- )
- with self.assertNoMessages():
- self.checker.visit_raise(raise_node)
-
- def test_ignores_returns_from_inner_functions(self) -> None:
- raise_node = astroid.extract_node(
- '''
- def my_func(self):
- """This is a docstring.
-
- :raises NameError: Never
- """
- def ex_func(val):
- def inner_func(value):
- return OSError(value)
- return RuntimeError(val)
- raise ex_func('hi') #@
- raise NameError('hi')
- '''
- )
- node = raise_node.frame()
- with self.assertAddsMessages(
- MessageTest(msg_id="missing-raises-doc", node=node, args=("RuntimeError",))
- ):
- # we do NOT expect a warning about the OSError in inner_func!
- self.checker.visit_raise(raise_node)
-
- def test_ignores_returns_use_only_names(self) -> None:
- raise_node = astroid.extract_node(
- '''
- def myfunc():
- """This is a docstring
-
- :raises NameError: Never
- """
- def inner_func():
- return 42
-
- raise inner_func() #@
- '''
- )
- with self.assertNoMessages():
- self.checker.visit_raise(raise_node)
-
- def test_ignores_returns_use_only_exception_instances(self) -> None:
- raise_node = astroid.extract_node(
- '''
- def myfunc():
- """This is a docstring
-
- :raises MyException: Never
- """
- class MyException(Exception):
- pass
- def inner_func():
- return MyException
-
- raise inner_func() #@
- '''
- )
- with self.assertNoMessages():
- self.checker.visit_raise(raise_node)
-
- def test_no_crash_when_inferring_handlers(self) -> None:
- raise_node = astroid.extract_node(
- '''
- import collections
-
- def test():
- """raises
-
- :raise U: pass
- """
- try:
- pass
- except collections.U as exc:
- raise #@
- '''
- )
- with self.assertNoMessages():
- self.checker.visit_raise(raise_node)
-
- def test_no_crash_when_cant_find_exception(self) -> None:
- raise_node = astroid.extract_node(
- '''
- import collections
-
- def test():
- """raises
-
- :raise U: pass
- """
- try:
- pass
- except U as exc:
- raise #@
- '''
- )
- with self.assertNoMessages():
- self.checker.visit_raise(raise_node)
-
- def test_no_error_notimplemented_documented(self) -> None:
- raise_node = astroid.extract_node(
- '''
- def my_func():
- """
- Raises:
- NotImplementedError: When called.
- """
- raise NotImplementedError #@
- '''
- )
- with self.assertNoMessages():
- self.checker.visit_raise(raise_node)
diff --git a/tests/functional/ext/docparams/raise/missing_raises_doc.py b/tests/functional/ext/docparams/raise/missing_raises_doc.py
new file mode 100644
index 000000000..280d9f8e7
--- /dev/null
+++ b/tests/functional/ext/docparams/raise/missing_raises_doc.py
@@ -0,0 +1,98 @@
+"""Tests for missing-raises-doc and missing-raises-type-doc"""
+# pylint: disable=function-redefined, invalid-name, undefined-variable, missing-function-docstring
+# pylint: disable=unused-argument, import-error, unused-variable, no-member, try-except-raise
+import collections
+
+from unknown import Unknown
+
+
+def test_ignores_no_docstring(self):
+ raise RuntimeError("hi")
+
+
+def test_ignores_unknown_style(self):
+ """This is a docstring."""
+ raise RuntimeError("hi")
+
+
+def test_ignores_raise_uninferable(self):
+ """This is a docstring.
+
+ :raises NameError: Never
+ """
+ raise Unknown("hi")
+ raise NameError("hi") # [unreachable]
+
+
+def test_ignores_returns_from_inner_functions(self): # [missing-raises-doc]
+ """This is a docstring.
+ We do NOT expect a warning about the OSError in inner_func!
+
+ :raises NameError: Never
+ """
+
+ def ex_func(val):
+ def inner_func(value):
+ return OSError(value)
+
+ return RuntimeError(val)
+
+ raise ex_func("hi")
+ raise NameError("hi") # [unreachable]
+
+
+def test_ignores_returns_use_only_names():
+ """This is a docstring
+
+ :raises NameError: Never
+ """
+
+ def inner_func():
+ return 42
+
+ raise inner_func() # [raising-bad-type]
+
+
+def test_ignores_returns_use_only_exception_instances():
+ """This is a docstring
+
+ :raises MyException: Never
+ """
+
+ class MyException(Exception):
+ """A docstring"""
+
+ def inner_func():
+ return MyException
+
+ raise inner_func()
+
+
+def test_no_crash_when_inferring_handlers():
+ """raises
+
+ :raise U: pass
+ """
+ try:
+ pass
+ except collections.U as exc:
+ raise
+
+
+def test_no_crash_when_cant_find_exception():
+ """raises
+
+ :raise U: pass
+ """
+ try:
+ pass
+ except U as exc:
+ raise
+
+
+def test_no_error_notimplemented_documented():
+ """
+ Raises:
+ NotImplementedError: When called.
+ """
+ raise NotImplementedError
diff --git a/tests/functional/ext/docparams/raise/missing_raises_doc.rc b/tests/functional/ext/docparams/raise/missing_raises_doc.rc
new file mode 100644
index 000000000..3c410593d
--- /dev/null
+++ b/tests/functional/ext/docparams/raise/missing_raises_doc.rc
@@ -0,0 +1,2 @@
+[MASTER]
+load-plugins = pylint.extensions.docparams
diff --git a/tests/functional/ext/docparams/raise/missing_raises_doc.txt b/tests/functional/ext/docparams/raise/missing_raises_doc.txt
new file mode 100644
index 000000000..6b11b43d0
--- /dev/null
+++ b/tests/functional/ext/docparams/raise/missing_raises_doc.txt
@@ -0,0 +1,4 @@
+unreachable:24:4:24:25:test_ignores_raise_uninferable:Unreachable code:UNDEFINED
+missing-raises-doc:27:0:41:25:test_ignores_returns_from_inner_functions:"""RuntimeError"" not documented as being raised":UNDEFINED
+unreachable:41:4:41:25:test_ignores_returns_from_inner_functions:Unreachable code:UNDEFINED
+raising-bad-type:53:4:53:22:test_ignores_returns_use_only_names:Raising int while only classes or instances are allowed:UNDEFINED
diff --git a/tests/functional/ext/docparams/raise/missing_raises_doc_Google.py b/tests/functional/ext/docparams/raise/missing_raises_doc_Google.py
new file mode 100644
index 000000000..83c68f0a5
--- /dev/null
+++ b/tests/functional/ext/docparams/raise/missing_raises_doc_Google.py
@@ -0,0 +1,138 @@
+"""Tests for missing-raises-doc and missing-raises-type-doc for Google style docstrings"""
+# pylint: disable=function-redefined, invalid-name, undefined-variable, missing-function-docstring
+# pylint: disable=unused-argument, import-outside-toplevel, import-error, try-except-raise
+
+
+def test_find_missing_google_raises(self): # [missing-raises-doc]
+ """This is a docstring.
+
+ Raises:
+ NameError: Never
+ """
+ raise RuntimeError("hi")
+ raise NameError("hi") # [unreachable]
+
+
+def test_find_google_attr_raises_exact_exc(self):
+ """This is a google docstring.
+
+ Raises:
+ re.error: Sometimes
+ """
+ import re
+
+ raise re.error("hi")
+
+
+def test_find_google_attr_raises_substr_exc(self):
+ """This is a google docstring.
+
+ Raises:
+ re.error: Sometimes
+ """
+ from re import error
+
+ raise error("hi")
+
+
+def test_find_valid_missing_google_attr_raises(self): # [missing-raises-doc]
+ """This is a google docstring.
+
+ Raises:
+ re.anothererror: Sometimes
+ """
+ from re import error
+
+ raise error("hi")
+
+
+def test_find_invalid_missing_google_attr_raises(self):
+ """This is a google docstring.
+ pylint allows this to pass since the comparison between Raises and
+ raise are based on the class name, not the qualified name.
+
+ Raises:
+ bogusmodule.error: Sometimes
+ """
+ from re import error
+
+ raise error("hi")
+
+
+def test_google_raises_local_reference(self):
+ """This is a google docstring.
+ pylint allows this to pass since the comparison between Raises and
+ raise are based on the class name, not the qualified name.
+
+ Raises:
+ .LocalException: Always
+ """
+ from neighbor_module import LocalException
+
+ raise LocalException("hi")
+
+
+def test_find_all_google_raises(self):
+ """This is a docstring.
+
+ Raises:
+ RuntimeError: Always
+ NameError: Never
+ """
+ raise RuntimeError("hi")
+ raise NameError("hi") # [unreachable]
+
+
+def test_find_multiple_google_raises(self):
+ """This is a docstring.
+
+ Raises:
+ RuntimeError: Always
+ NameError, OSError, ValueError: Never
+ """
+ raise RuntimeError("hi")
+ raise NameError("hi") # [unreachable]
+ raise OSError(2, "abort!") # [unreachable]
+ raise ValueError("foo") # [unreachable]
+
+
+def test_find_rethrown_google_raises(self): # [missing-raises-doc]
+ """This is a docstring.
+
+ Raises:
+ NameError: Sometimes
+ """
+ try:
+ fake_func()
+ except RuntimeError:
+ raise
+
+ raise NameError("hi")
+
+
+def test_find_rethrown_google_multiple_raises(self): # [missing-raises-doc]
+ """This is a docstring.
+
+ Raises:
+ NameError: Sometimes
+ """
+ try:
+ fake_func()
+ except (RuntimeError, ValueError):
+ raise
+
+ raise NameError("hi")
+
+
+def test_ignores_caught_google_raises(self):
+ """This is a docstring.
+
+ Raises:
+ NameError: Sometimes
+ """
+ try:
+ raise RuntimeError("hi")
+ except RuntimeError:
+ pass
+
+ raise NameError("hi")
diff --git a/tests/functional/ext/docparams/raise/missing_raises_doc_Google.rc b/tests/functional/ext/docparams/raise/missing_raises_doc_Google.rc
new file mode 100644
index 000000000..3c410593d
--- /dev/null
+++ b/tests/functional/ext/docparams/raise/missing_raises_doc_Google.rc
@@ -0,0 +1,2 @@
+[MASTER]
+load-plugins = pylint.extensions.docparams
diff --git a/tests/functional/ext/docparams/raise/missing_raises_doc_Google.txt b/tests/functional/ext/docparams/raise/missing_raises_doc_Google.txt
new file mode 100644
index 000000000..17fbc279d
--- /dev/null
+++ b/tests/functional/ext/docparams/raise/missing_raises_doc_Google.txt
@@ -0,0 +1,9 @@
+missing-raises-doc:6:0:13:25:test_find_missing_google_raises:"""RuntimeError"" not documented as being raised":UNDEFINED
+unreachable:13:4:13:25:test_find_missing_google_raises:Unreachable code:UNDEFINED
+missing-raises-doc:38:0:46:21:test_find_valid_missing_google_attr_raises:"""error"" not documented as being raised":UNDEFINED
+unreachable:83:4:83:25:test_find_all_google_raises:Unreachable code:UNDEFINED
+unreachable:94:4:94:25:test_find_multiple_google_raises:Unreachable code:UNDEFINED
+unreachable:95:4:95:30:test_find_multiple_google_raises:Unreachable code:UNDEFINED
+unreachable:96:4:96:27:test_find_multiple_google_raises:Unreachable code:UNDEFINED
+missing-raises-doc:99:0:110:25:test_find_rethrown_google_raises:"""RuntimeError"" not documented as being raised":UNDEFINED
+missing-raises-doc:113:0:124:25:test_find_rethrown_google_multiple_raises:"""RuntimeError, ValueError"" not documented as being raised":UNDEFINED
diff --git a/tests/functional/ext/docparams/raise/missing_raises_doc_Numpy.py b/tests/functional/ext/docparams/raise/missing_raises_doc_Numpy.py
new file mode 100644
index 000000000..b9ac54660
--- /dev/null
+++ b/tests/functional/ext/docparams/raise/missing_raises_doc_Numpy.py
@@ -0,0 +1,131 @@
+"""Tests for missing-raises-doc and missing-raises-type-doc for Numpy style docstrings"""
+# pylint: disable=function-redefined, invalid-name, undefined-variable, missing-function-docstring
+# pylint: disable=unused-argument, try-except-raise, import-outside-toplevel
+
+
+def test_find_missing_numpy_raises(self): # [missing-raises-doc]
+ """This is a docstring.
+
+ Raises
+ ------
+ NameError
+ Never
+ """
+ raise RuntimeError("hi")
+ raise NameError("hi") # [unreachable]
+
+
+def test_find_all_numpy_raises(self):
+ """This is a docstring.
+
+ Raises
+ ------
+ RuntimeError
+ Always
+ NameError
+ Never
+ """
+ raise RuntimeError("hi")
+ raise NameError("hi") # [unreachable]
+
+
+def test_find_rethrown_numpy_raises(self): # [missing-raises-doc]
+ """This is a docstring.
+
+ Raises
+ ------
+ NameError
+ Sometimes
+ """
+ try:
+ fake_func()
+ except RuntimeError:
+ raise
+
+ raise NameError("hi")
+
+
+def test_find_rethrown_numpy_multiple_raises(self): # [missing-raises-doc]
+ """This is a docstring.
+
+ Raises
+ ------
+ NameError
+ Sometimes
+ """
+ try:
+ fake_func()
+ except (RuntimeError, ValueError):
+ raise
+
+ raise NameError("hi")
+
+
+def test_ignores_caught_numpy_raises(self):
+ """This is a numpy docstring.
+
+ Raises
+ ------
+ NameError
+ Sometimes
+ """
+ try:
+ raise RuntimeError("hi")
+ except RuntimeError:
+ pass
+
+ raise NameError("hi")
+
+
+def test_find_numpy_attr_raises_exact_exc(self):
+ """This is a numpy docstring.
+
+ Raises
+ ------
+ re.error
+ Sometimes
+ """
+ import re
+
+ raise re.error("hi")
+
+
+def test_find_numpy_attr_raises_substr_exc(self):
+ """This is a numpy docstring.
+
+ Raises
+ ------
+ re.error
+ Sometimes
+ """
+ from re import error
+
+ raise error("hi")
+
+
+def test_find_valid_missing_numpy_attr_raises(self): # [missing-raises-doc]
+ """This is a numpy docstring.
+
+ Raises
+ ------
+ re.anothererror
+ Sometimes
+ """
+ from re import error
+
+ raise error("hi")
+
+
+def test_find_invalid_missing_numpy_attr_raises(self):
+ """This is a numpy docstring.
+ pylint allows this to pass since the comparison between Raises and
+ raise are based on the class name, not the qualified name.
+
+ Raises
+ ------
+ bogusmodule.error
+ Sometimes
+ """
+ from re import error
+
+ raise error("hi")
diff --git a/tests/functional/ext/docparams/raise/missing_raises_doc_Numpy.rc b/tests/functional/ext/docparams/raise/missing_raises_doc_Numpy.rc
new file mode 100644
index 000000000..3c410593d
--- /dev/null
+++ b/tests/functional/ext/docparams/raise/missing_raises_doc_Numpy.rc
@@ -0,0 +1,2 @@
+[MASTER]
+load-plugins = pylint.extensions.docparams
diff --git a/tests/functional/ext/docparams/raise/missing_raises_doc_Numpy.txt b/tests/functional/ext/docparams/raise/missing_raises_doc_Numpy.txt
new file mode 100644
index 000000000..b6573e38a
--- /dev/null
+++ b/tests/functional/ext/docparams/raise/missing_raises_doc_Numpy.txt
@@ -0,0 +1,6 @@
+missing-raises-doc:6:0:15:25:test_find_missing_numpy_raises:"""RuntimeError"" not documented as being raised":UNDEFINED
+unreachable:15:4:15:25:test_find_missing_numpy_raises:Unreachable code:UNDEFINED
+unreachable:29:4:29:25:test_find_all_numpy_raises:Unreachable code:UNDEFINED
+missing-raises-doc:32:0:45:25:test_find_rethrown_numpy_raises:"""RuntimeError"" not documented as being raised":UNDEFINED
+missing-raises-doc:48:0:61:25:test_find_rethrown_numpy_multiple_raises:"""RuntimeError, ValueError"" not documented as being raised":UNDEFINED
+missing-raises-doc:106:0:116:21:test_find_valid_missing_numpy_attr_raises:"""error"" not documented as being raised":UNDEFINED
diff --git a/tests/functional/ext/docparams/raise/missing_raises_doc_Sphinx.py b/tests/functional/ext/docparams/raise/missing_raises_doc_Sphinx.py
new file mode 100644
index 000000000..4658705cd
--- /dev/null
+++ b/tests/functional/ext/docparams/raise/missing_raises_doc_Sphinx.py
@@ -0,0 +1,151 @@
+"""Tests for missing-raises-doc and missing-raises-type-doc for Sphinx style docstrings"""
+# pylint: disable=function-redefined, invalid-name, undefined-variable, missing-function-docstring
+# pylint: disable=unused-argument, try-except-raise, import-outside-toplevel
+
+
+def test_find_missing_sphinx_raises(self): # [missing-raises-doc]
+ """This is a docstring.
+
+ :raises NameError: Never
+ """
+ raise RuntimeError("hi")
+ raise NameError("hi") # [unreachable]
+
+
+def test_ignore_spurious_sphinx_raises(self):
+ """This is a docstring.
+
+ :raises RuntimeError: Always
+ :except NameError: Never
+ :raise OSError: Never
+ :exception ValueError: Never
+ """
+ raise RuntimeError("Blah")
+
+
+def test_find_all_sphinx_raises(self):
+ """This is a docstring.
+
+ :raises RuntimeError: Always
+ :except NameError: Never
+ :raise OSError: Never
+ :exception ValueError: Never
+ """
+ raise RuntimeError("hi")
+ raise NameError("hi") # [unreachable]
+ raise OSError(2, "abort!") # [unreachable]
+ raise ValueError("foo") # [unreachable]
+
+
+def test_find_multiple_sphinx_raises(self):
+ """This is a docstring.
+
+ :raises RuntimeError: Always
+ :raises NameError, OSError, ValueError: Never
+ """
+ raise RuntimeError("hi")
+ raise NameError("hi") # [unreachable]
+
+
+def test_finds_rethrown_sphinx_raises(self): # [missing-raises-doc]
+ """This is a docstring.
+
+ :raises NameError: Sometimes
+ """
+ try:
+ fake_func()
+ except RuntimeError:
+ raise
+
+ raise NameError("hi")
+
+
+def test_finds_rethrown_sphinx_multiple_raises(self): # [missing-raises-doc]
+ """This is a docstring.
+
+ :raises NameError: Sometimes
+ """
+ try:
+ fake_func()
+ except (RuntimeError, ValueError):
+ raise
+
+ raise NameError("hi")
+
+
+def test_ignores_caught_sphinx_raises(self):
+ """This is a docstring.
+
+ :raises NameError: Sometimes
+ """
+ try:
+ raise RuntimeError("hi")
+ except RuntimeError:
+ pass
+
+ raise NameError("hi")
+
+
+def test_find_missing_sphinx_raises_infer_from_instance(self): # [missing-raises-doc]
+ """This is a docstring.
+
+ :raises NameError: Never
+ """
+ my_exception = RuntimeError("hi")
+ raise my_exception
+ raise NameError("hi") # [unreachable]
+
+
+def test_find_missing_sphinx_raises_infer_from_function(self): # [missing-raises-doc]
+ """This is a docstring.
+
+ :raises NameError: Never
+ """
+
+ def ex_func(val):
+ return RuntimeError(val)
+
+ raise ex_func("hi")
+ raise NameError("hi") # [unreachable]
+
+
+def test_find_sphinx_attr_raises_exact_exc(self):
+ """This is a sphinx docstring.
+
+ :raises re.error: Sometimes
+ """
+ import re
+
+ raise re.error("hi")
+
+
+def test_find_sphinx_attr_raises_substr_exc(self):
+ """This is a sphinx docstring.
+
+ :raises re.error: Sometimes
+ """
+ from re import error
+
+ raise error("hi")
+
+
+def test_find_valid_missing_sphinx_attr_raises(self): # [missing-raises-doc]
+ """This is a sphinx docstring.
+
+ :raises re.anothererror: Sometimes
+ """
+ from re import error
+
+ raise error("hi")
+
+
+def test_find_invalid_missing_sphinx_attr_raises(self):
+ """This is a sphinx docstring.
+ pylint allows this to pass since the comparison between Raises and
+ raise are based on the class name, not the qualified name.
+
+ :raises bogusmodule.error: Sometimes
+ """
+ from re import error
+
+ raise error("hi")
diff --git a/tests/functional/ext/docparams/raise/missing_raises_doc_Sphinx.rc b/tests/functional/ext/docparams/raise/missing_raises_doc_Sphinx.rc
new file mode 100644
index 000000000..3c410593d
--- /dev/null
+++ b/tests/functional/ext/docparams/raise/missing_raises_doc_Sphinx.rc
@@ -0,0 +1,2 @@
+[MASTER]
+load-plugins = pylint.extensions.docparams
diff --git a/tests/functional/ext/docparams/raise/missing_raises_doc_Sphinx.txt b/tests/functional/ext/docparams/raise/missing_raises_doc_Sphinx.txt
new file mode 100644
index 000000000..e5a091e46
--- /dev/null
+++ b/tests/functional/ext/docparams/raise/missing_raises_doc_Sphinx.txt
@@ -0,0 +1,13 @@
+missing-raises-doc:6:0:12:25:test_find_missing_sphinx_raises:"""RuntimeError"" not documented as being raised":UNDEFINED
+unreachable:12:4:12:25:test_find_missing_sphinx_raises:Unreachable code:UNDEFINED
+unreachable:35:4:35:25:test_find_all_sphinx_raises:Unreachable code:UNDEFINED
+unreachable:36:4:36:30:test_find_all_sphinx_raises:Unreachable code:UNDEFINED
+unreachable:37:4:37:27:test_find_all_sphinx_raises:Unreachable code:UNDEFINED
+unreachable:47:4:47:25:test_find_multiple_sphinx_raises:Unreachable code:UNDEFINED
+missing-raises-doc:50:0:60:25:test_finds_rethrown_sphinx_raises:"""RuntimeError"" not documented as being raised":UNDEFINED
+missing-raises-doc:63:0:73:25:test_finds_rethrown_sphinx_multiple_raises:"""RuntimeError, ValueError"" not documented as being raised":UNDEFINED
+missing-raises-doc:89:0:96:25:test_find_missing_sphinx_raises_infer_from_instance:"""RuntimeError"" not documented as being raised":UNDEFINED
+unreachable:96:4:96:25:test_find_missing_sphinx_raises_infer_from_instance:Unreachable code:UNDEFINED
+missing-raises-doc:99:0:109:25:test_find_missing_sphinx_raises_infer_from_function:"""RuntimeError"" not documented as being raised":UNDEFINED
+unreachable:109:4:109:25:test_find_missing_sphinx_raises_infer_from_function:Unreachable code:UNDEFINED
+missing-raises-doc:132:0:139:21:test_find_valid_missing_sphinx_attr_raises:"""error"" not documented as being raised":UNDEFINED
diff --git a/tests/functional/ext/docparams/raise/missing_raises_doc_required.py b/tests/functional/ext/docparams/raise/missing_raises_doc_required.py
new file mode 100644
index 000000000..860a3ecf5
--- /dev/null
+++ b/tests/functional/ext/docparams/raise/missing_raises_doc_required.py
@@ -0,0 +1,8 @@
+"""Tests for missing-raises-doc and missing-raises-type-doc with accept-no-raise-doc = no"""
+# pylint: disable=function-redefined, invalid-name, undefined-variable, missing-function-docstring
+# pylint: disable=unused-argument
+
+
+def test_warns_unknown_style(self): # [missing-raises-doc]
+ """This is a docstring."""
+ raise RuntimeError("hi")
diff --git a/tests/functional/ext/docparams/raise/missing_raises_doc_required.rc b/tests/functional/ext/docparams/raise/missing_raises_doc_required.rc
new file mode 100644
index 000000000..098921070
--- /dev/null
+++ b/tests/functional/ext/docparams/raise/missing_raises_doc_required.rc
@@ -0,0 +1,5 @@
+[MASTER]
+load-plugins = pylint.extensions.docparams
+
+[BASIC]
+accept-no-raise-doc=no
diff --git a/tests/functional/ext/docparams/raise/missing_raises_doc_required.txt b/tests/functional/ext/docparams/raise/missing_raises_doc_required.txt
new file mode 100644
index 000000000..3c9f68e16
--- /dev/null
+++ b/tests/functional/ext/docparams/raise/missing_raises_doc_required.txt
@@ -0,0 +1 @@
+missing-raises-doc:6:0:8:28:test_warns_unknown_style:"""RuntimeError"" not documented as being raised":UNDEFINED
diff --git a/tests/functional/ext/docparams/raise/missing_raises_doc_required_Google.py b/tests/functional/ext/docparams/raise/missing_raises_doc_required_Google.py
new file mode 100644
index 000000000..f5985347b
--- /dev/null
+++ b/tests/functional/ext/docparams/raise/missing_raises_doc_required_Google.py
@@ -0,0 +1,26 @@
+"""Tests for missing-raises-doc and missing-raises-type-doc for Google style docstrings
+with accept-no-raise-doc = no"""
+# pylint: disable=function-redefined, invalid-name, undefined-variable, missing-function-docstring
+# pylint: disable=unused-argument, import-outside-toplevel
+
+
+def test_google_raises_with_prefix_one(self):
+ """This is a google docstring.
+
+ Raises:
+ ~re.error: Sometimes
+ """
+ import re
+
+ raise re.error("hi")
+
+
+def test_google_raises_with_prefix_two(self):
+ """This is a google docstring.
+
+ Raises:
+ !re.error: Sometimes
+ """
+ import re
+
+ raise re.error("hi")
diff --git a/tests/functional/ext/docparams/raise/missing_raises_doc_required_Google.rc b/tests/functional/ext/docparams/raise/missing_raises_doc_required_Google.rc
new file mode 100644
index 000000000..098921070
--- /dev/null
+++ b/tests/functional/ext/docparams/raise/missing_raises_doc_required_Google.rc
@@ -0,0 +1,5 @@
+[MASTER]
+load-plugins = pylint.extensions.docparams
+
+[BASIC]
+accept-no-raise-doc=no
diff --git a/tests/functional/ext/docparams/raise/missing_raises_doc_required_Numpy.py b/tests/functional/ext/docparams/raise/missing_raises_doc_required_Numpy.py
new file mode 100644
index 000000000..1577f96f3
--- /dev/null
+++ b/tests/functional/ext/docparams/raise/missing_raises_doc_required_Numpy.py
@@ -0,0 +1,30 @@
+"""Tests for missing-raises-doc and missing-raises-type-doc for Numpy style docstrings
+with accept-no-raise-doc = no"""
+# pylint: disable=function-redefined, invalid-name, undefined-variable, missing-function-docstring
+# pylint: disable=unused-argument, import-outside-toplevel
+
+
+def test_numpy_raises_with_prefix_one(self):
+ """This is a numpy docstring.
+
+ Raises
+ ------
+ ~re.error
+ Sometimes
+ """
+ import re
+
+ raise re.error("hi")
+
+
+def test_numpy_raises_with_prefix_two(self):
+ """This is a numpy docstring.
+
+ Raises
+ ------
+ !re.error
+ Sometimes
+ """
+ import re
+
+ raise re.error("hi")
diff --git a/tests/functional/ext/docparams/raise/missing_raises_doc_required_Numpy.rc b/tests/functional/ext/docparams/raise/missing_raises_doc_required_Numpy.rc
new file mode 100644
index 000000000..098921070
--- /dev/null
+++ b/tests/functional/ext/docparams/raise/missing_raises_doc_required_Numpy.rc
@@ -0,0 +1,5 @@
+[MASTER]
+load-plugins = pylint.extensions.docparams
+
+[BASIC]
+accept-no-raise-doc=no
diff --git a/tests/functional/ext/docparams/raise/missing_raises_doc_required_Sphinx.py b/tests/functional/ext/docparams/raise/missing_raises_doc_required_Sphinx.py
new file mode 100644
index 000000000..eee878680
--- /dev/null
+++ b/tests/functional/ext/docparams/raise/missing_raises_doc_required_Sphinx.py
@@ -0,0 +1,24 @@
+"""Tests for missing-raises-doc and missing-raises-type-doc for Sphinx style docstrings
+with accept-no-raise-doc = no"""
+# pylint: disable=function-redefined, invalid-name, undefined-variable, missing-function-docstring
+# pylint: disable=unused-argument, import-outside-toplevel
+
+
+def test_sphinx_raises_with_prefix_one(self):
+ """This is a sphinx docstring.
+
+ :raises ~re.error: Sometimes
+ """
+ import re
+
+ raise re.error("hi")
+
+
+def test_sphinx_raises_with_prefix_two(self):
+ """This is a sphinx docstring.
+
+ :raises !re.error: Sometimes
+ """
+ import re
+
+ raise re.error("hi")
diff --git a/tests/functional/ext/docparams/raise/missing_raises_doc_required_Sphinx.rc b/tests/functional/ext/docparams/raise/missing_raises_doc_required_Sphinx.rc
new file mode 100644
index 000000000..098921070
--- /dev/null
+++ b/tests/functional/ext/docparams/raise/missing_raises_doc_required_Sphinx.rc
@@ -0,0 +1,5 @@
+[MASTER]
+load-plugins = pylint.extensions.docparams
+
+[BASIC]
+accept-no-raise-doc=no