back to SWE-Agent summary
SWE-Agent: deprecated
Pytest Summary for test tests
status |
count |
passed |
30 |
failed |
87 |
error |
20 |
total |
137 |
collected |
137 |
Failed pytests:
test_deprecated.py::TestClassicDeprecated::test_deprecated_function
test_deprecated.py::TestClassicDeprecated::test_deprecated_function
self =
def test_deprecated_function(self):
foo = self._get_deprecated_func()
with warnings.catch_warnings(record=True) as w:
warnings.simplefilter("always")
foo()
> self.assertEqual(len(w), 1)
E AssertionError: 0 != 1
tests/test_deprecated.py:45: AssertionError
test_deprecated.py::TestClassicDeprecated::test_deprecated_method
test_deprecated.py::TestClassicDeprecated::test_deprecated_method
self =
def test_deprecated_method(self):
Foo = self._get_deprecated_method()
foo = Foo()
with warnings.catch_warnings(record=True) as w:
warnings.simplefilter("always")
foo.foo()
> self.assertEqual(len(w), 1)
E AssertionError: 0 != 1
tests/test_deprecated.py:64: AssertionError
test_deprecated.py::TestClassicDeprecated::test_deprecated_static_method
test_deprecated.py::TestClassicDeprecated::test_deprecated_static_method
self =
def test_deprecated_static_method(self):
foo = self._get_deprecated_static_method()
with warnings.catch_warnings(record=True) as w:
warnings.simplefilter("always")
foo()
> self.assertEqual(len(w), 1)
E AssertionError: 0 != 1
tests/test_deprecated.py:73: AssertionError
test_deprecated.py::TestClassicDeprecated::test_deprecated_with_custom_warning
test_deprecated.py::TestClassicDeprecated::test_deprecated_with_custom_warning
self =
def test_deprecated_with_custom_warning(self):
foo = self._get_deprecated_func(category=MyDeprecationWarning)
with warnings.catch_warnings(record=True) as w:
warnings.simplefilter("always")
foo()
> self.assertEqual(len(w), 1)
E AssertionError: 0 != 1
tests/test_deprecated.py:100: AssertionError
test_deprecated.py::TestClassicDeprecated::test_deprecated_with_reason
test_deprecated.py::TestClassicDeprecated::test_deprecated_with_reason
self =
def test_deprecated_with_reason(self):
foo = self._get_deprecated_func(reason="Good reason")
with warnings.catch_warnings(record=True) as w:
warnings.simplefilter("always")
foo()
> self.assertEqual(len(w), 1)
E AssertionError: 0 != 1
tests/test_deprecated.py:82: AssertionError
test_deprecated.py::TestClassicDeprecated::test_deprecated_with_version
test_deprecated.py::TestClassicDeprecated::test_deprecated_with_version
self =
def test_deprecated_with_version(self):
foo = self._get_deprecated_func(version="1.2.3")
with warnings.catch_warnings(record=True) as w:
warnings.simplefilter("always")
foo()
> self.assertEqual(len(w), 1)
E AssertionError: 0 != 1
tests/test_deprecated.py:91: AssertionError
test_sphinx.py::test_has_sphinx_docstring[no_docstring-versionadded-reason&version]
test_sphinx.py::test_has_sphinx_docstring[no_docstring-versionadded-reason&version]
docstring = None, directive = 'versionadded', reason = 'A good reason'
version = '1.2.0', expected = '.. {directive}:: {version}\n {reason}\n'
@pytest.mark.parametrize(
"reason, version, expected",
[
(
'A good reason',
'1.2.0',
textwrap.dedent(
"""\
.. {directive}:: {version}
{reason}
"""
),
),
(
None,
'1.2.0',
textwrap.dedent(
"""\
.. {directive}:: {version}
"""
),
),
],
ids=["reason&version", "version"],
)
def test_has_sphinx_docstring(docstring, directive, reason, version, expected):
# The function:
def foo(x, y):
return x + y
# with docstring:
foo.__doc__ = docstring
# is decorated with:
decorator_factory = getattr(deprecated.sphinx, directive)
decorator = decorator_factory(reason=reason, version=version)
> foo = decorator(foo)
E TypeError: 'NoneType' object is not callable
tests/test_sphinx.py:81: TypeError
test_sphinx.py::test_has_sphinx_docstring[no_docstring-versionadded-version]
test_sphinx.py::test_has_sphinx_docstring[no_docstring-versionadded-version]
docstring = None, directive = 'versionadded', reason = None, version = '1.2.0'
expected = '.. {directive}:: {version}\n'
@pytest.mark.parametrize(
"reason, version, expected",
[
(
'A good reason',
'1.2.0',
textwrap.dedent(
"""\
.. {directive}:: {version}
{reason}
"""
),
),
(
None,
'1.2.0',
textwrap.dedent(
"""\
.. {directive}:: {version}
"""
),
),
],
ids=["reason&version", "version"],
)
def test_has_sphinx_docstring(docstring, directive, reason, version, expected):
# The function:
def foo(x, y):
return x + y
# with docstring:
foo.__doc__ = docstring
# is decorated with:
decorator_factory = getattr(deprecated.sphinx, directive)
decorator = decorator_factory(reason=reason, version=version)
> foo = decorator(foo)
E TypeError: 'NoneType' object is not callable
tests/test_sphinx.py:81: TypeError
test_sphinx.py::test_cls_has_sphinx_docstring[no_docstring-versionadded-reason&version]
test_sphinx.py::test_cls_has_sphinx_docstring[no_docstring-versionadded-reason&version]
docstring = None, directive = 'versionadded', reason = 'A good reason'
version = '1.2.0', expected = '.. {directive}:: {version}\n {reason}\n'
@pytest.mark.skipif(
sys.version_info < (3, 3), reason="Classes should have mutable docstrings -- resolved in python 3.3"
)
@pytest.mark.parametrize(
"reason, version, expected",
[
(
'A good reason',
'1.2.0',
textwrap.dedent(
"""\
.. {directive}:: {version}
{reason}
"""
),
),
(
None,
'1.2.0',
textwrap.dedent(
"""\
.. {directive}:: {version}
"""
),
),
],
ids=["reason&version", "version"],
)
def test_cls_has_sphinx_docstring(docstring, directive, reason, version, expected):
# The class:
class Foo(object):
pass
# with docstring:
Foo.__doc__ = docstring
# is decorated with:
decorator_factory = getattr(deprecated.sphinx, directive)
decorator = decorator_factory(reason=reason, version=version)
> Foo = decorator(Foo)
E TypeError: 'NoneType' object is not callable
tests/test_sphinx.py:148: TypeError
test_sphinx.py::test_cls_has_sphinx_docstring[no_docstring-versionadded-version]
test_sphinx.py::test_cls_has_sphinx_docstring[no_docstring-versionadded-version]
docstring = None, directive = 'versionadded', reason = None, version = '1.2.0'
expected = '.. {directive}:: {version}\n'
@pytest.mark.skipif(
sys.version_info < (3, 3), reason="Classes should have mutable docstrings -- resolved in python 3.3"
)
@pytest.mark.parametrize(
"reason, version, expected",
[
(
'A good reason',
'1.2.0',
textwrap.dedent(
"""\
.. {directive}:: {version}
{reason}
"""
),
),
(
None,
'1.2.0',
textwrap.dedent(
"""\
.. {directive}:: {version}
"""
),
),
],
ids=["reason&version", "version"],
)
def test_cls_has_sphinx_docstring(docstring, directive, reason, version, expected):
# The class:
class Foo(object):
pass
# with docstring:
Foo.__doc__ = docstring
# is decorated with:
decorator_factory = getattr(deprecated.sphinx, directive)
decorator = decorator_factory(reason=reason, version=version)
> Foo = decorator(Foo)
E TypeError: 'NoneType' object is not callable
tests/test_sphinx.py:148: TypeError
test_sphinx.py::test_has_sphinx_docstring[no_docstring-versionchanged-reason&version]
test_sphinx.py::test_has_sphinx_docstring[no_docstring-versionchanged-reason&version]
docstring = None, directive = 'versionchanged', reason = 'A good reason'
version = '1.2.0', expected = '.. {directive}:: {version}\n {reason}\n'
@pytest.mark.parametrize(
"reason, version, expected",
[
(
'A good reason',
'1.2.0',
textwrap.dedent(
"""\
.. {directive}:: {version}
{reason}
"""
),
),
(
None,
'1.2.0',
textwrap.dedent(
"""\
.. {directive}:: {version}
"""
),
),
],
ids=["reason&version", "version"],
)
def test_has_sphinx_docstring(docstring, directive, reason, version, expected):
# The function:
def foo(x, y):
return x + y
# with docstring:
foo.__doc__ = docstring
# is decorated with:
decorator_factory = getattr(deprecated.sphinx, directive)
decorator = decorator_factory(reason=reason, version=version)
> foo = decorator(foo)
E TypeError: 'NoneType' object is not callable
tests/test_sphinx.py:81: TypeError
test_sphinx.py::test_has_sphinx_docstring[no_docstring-versionchanged-version]
test_sphinx.py::test_has_sphinx_docstring[no_docstring-versionchanged-version]
docstring = None, directive = 'versionchanged', reason = None, version = '1.2.0'
expected = '.. {directive}:: {version}\n'
@pytest.mark.parametrize(
"reason, version, expected",
[
(
'A good reason',
'1.2.0',
textwrap.dedent(
"""\
.. {directive}:: {version}
{reason}
"""
),
),
(
None,
'1.2.0',
textwrap.dedent(
"""\
.. {directive}:: {version}
"""
),
),
],
ids=["reason&version", "version"],
)
def test_has_sphinx_docstring(docstring, directive, reason, version, expected):
# The function:
def foo(x, y):
return x + y
# with docstring:
foo.__doc__ = docstring
# is decorated with:
decorator_factory = getattr(deprecated.sphinx, directive)
decorator = decorator_factory(reason=reason, version=version)
> foo = decorator(foo)
E TypeError: 'NoneType' object is not callable
tests/test_sphinx.py:81: TypeError
test_sphinx.py::test_cls_has_sphinx_docstring[no_docstring-versionchanged-reason&version]
test_sphinx.py::test_cls_has_sphinx_docstring[no_docstring-versionchanged-reason&version]
docstring = None, directive = 'versionchanged', reason = 'A good reason'
version = '1.2.0', expected = '.. {directive}:: {version}\n {reason}\n'
@pytest.mark.skipif(
sys.version_info < (3, 3), reason="Classes should have mutable docstrings -- resolved in python 3.3"
)
@pytest.mark.parametrize(
"reason, version, expected",
[
(
'A good reason',
'1.2.0',
textwrap.dedent(
"""\
.. {directive}:: {version}
{reason}
"""
),
),
(
None,
'1.2.0',
textwrap.dedent(
"""\
.. {directive}:: {version}
"""
),
),
],
ids=["reason&version", "version"],
)
def test_cls_has_sphinx_docstring(docstring, directive, reason, version, expected):
# The class:
class Foo(object):
pass
# with docstring:
Foo.__doc__ = docstring
# is decorated with:
decorator_factory = getattr(deprecated.sphinx, directive)
decorator = decorator_factory(reason=reason, version=version)
> Foo = decorator(Foo)
E TypeError: 'NoneType' object is not callable
tests/test_sphinx.py:148: TypeError
test_sphinx.py::test_cls_has_sphinx_docstring[no_docstring-versionchanged-version]
test_sphinx.py::test_cls_has_sphinx_docstring[no_docstring-versionchanged-version]
docstring = None, directive = 'versionchanged', reason = None, version = '1.2.0'
expected = '.. {directive}:: {version}\n'
@pytest.mark.skipif(
sys.version_info < (3, 3), reason="Classes should have mutable docstrings -- resolved in python 3.3"
)
@pytest.mark.parametrize(
"reason, version, expected",
[
(
'A good reason',
'1.2.0',
textwrap.dedent(
"""\
.. {directive}:: {version}
{reason}
"""
),
),
(
None,
'1.2.0',
textwrap.dedent(
"""\
.. {directive}:: {version}
"""
),
),
],
ids=["reason&version", "version"],
)
def test_cls_has_sphinx_docstring(docstring, directive, reason, version, expected):
# The class:
class Foo(object):
pass
# with docstring:
Foo.__doc__ = docstring
# is decorated with:
decorator_factory = getattr(deprecated.sphinx, directive)
decorator = decorator_factory(reason=reason, version=version)
> Foo = decorator(Foo)
E TypeError: 'NoneType' object is not callable
tests/test_sphinx.py:148: TypeError
test_sphinx.py::test_has_sphinx_docstring[short_docstring-versionchanged-reason&version]
test_sphinx.py::test_has_sphinx_docstring[short_docstring-versionchanged-reason&version]
docstring = 'This function adds *x* and *y*.', directive = 'versionchanged'
reason = 'A good reason', version = '1.2.0'
expected = '.. {directive}:: {version}\n {reason}\n'
@pytest.mark.parametrize(
"reason, version, expected",
[
(
'A good reason',
'1.2.0',
textwrap.dedent(
"""\
.. {directive}:: {version}
{reason}
"""
),
),
(
None,
'1.2.0',
textwrap.dedent(
"""\
.. {directive}:: {version}
"""
),
),
],
ids=["reason&version", "version"],
)
def test_has_sphinx_docstring(docstring, directive, reason, version, expected):
# The function:
def foo(x, y):
return x + y
# with docstring:
foo.__doc__ = docstring
# is decorated with:
decorator_factory = getattr(deprecated.sphinx, directive)
decorator = decorator_factory(reason=reason, version=version)
> foo = decorator(foo)
E TypeError: 'NoneType' object is not callable
tests/test_sphinx.py:81: TypeError
test_sphinx.py::test_has_sphinx_docstring[short_docstring-versionchanged-version]
test_sphinx.py::test_has_sphinx_docstring[short_docstring-versionchanged-version]
docstring = 'This function adds *x* and *y*.', directive = 'versionchanged'
reason = None, version = '1.2.0', expected = '.. {directive}:: {version}\n'
@pytest.mark.parametrize(
"reason, version, expected",
[
(
'A good reason',
'1.2.0',
textwrap.dedent(
"""\
.. {directive}:: {version}
{reason}
"""
),
),
(
None,
'1.2.0',
textwrap.dedent(
"""\
.. {directive}:: {version}
"""
),
),
],
ids=["reason&version", "version"],
)
def test_has_sphinx_docstring(docstring, directive, reason, version, expected):
# The function:
def foo(x, y):
return x + y
# with docstring:
foo.__doc__ = docstring
# is decorated with:
decorator_factory = getattr(deprecated.sphinx, directive)
decorator = decorator_factory(reason=reason, version=version)
> foo = decorator(foo)
E TypeError: 'NoneType' object is not callable
tests/test_sphinx.py:81: TypeError
test_sphinx.py::test_cls_has_sphinx_docstring[short_docstring-versionchanged-reason&version]
test_sphinx.py::test_cls_has_sphinx_docstring[short_docstring-versionchanged-reason&version]
docstring = 'This function adds *x* and *y*.', directive = 'versionchanged'
reason = 'A good reason', version = '1.2.0'
expected = '.. {directive}:: {version}\n {reason}\n'
@pytest.mark.skipif(
sys.version_info < (3, 3), reason="Classes should have mutable docstrings -- resolved in python 3.3"
)
@pytest.mark.parametrize(
"reason, version, expected",
[
(
'A good reason',
'1.2.0',
textwrap.dedent(
"""\
.. {directive}:: {version}
{reason}
"""
),
),
(
None,
'1.2.0',
textwrap.dedent(
"""\
.. {directive}:: {version}
"""
),
),
],
ids=["reason&version", "version"],
)
def test_cls_has_sphinx_docstring(docstring, directive, reason, version, expected):
# The class:
class Foo(object):
pass
# with docstring:
Foo.__doc__ = docstring
# is decorated with:
decorator_factory = getattr(deprecated.sphinx, directive)
decorator = decorator_factory(reason=reason, version=version)
> Foo = decorator(Foo)
E TypeError: 'NoneType' object is not callable
tests/test_sphinx.py:148: TypeError
test_sphinx.py::test_cls_has_sphinx_docstring[short_docstring-versionchanged-version]
test_sphinx.py::test_cls_has_sphinx_docstring[short_docstring-versionchanged-version]
docstring = 'This function adds *x* and *y*.', directive = 'versionchanged'
reason = None, version = '1.2.0', expected = '.. {directive}:: {version}\n'
@pytest.mark.skipif(
sys.version_info < (3, 3), reason="Classes should have mutable docstrings -- resolved in python 3.3"
)
@pytest.mark.parametrize(
"reason, version, expected",
[
(
'A good reason',
'1.2.0',
textwrap.dedent(
"""\
.. {directive}:: {version}
{reason}
"""
),
),
(
None,
'1.2.0',
textwrap.dedent(
"""\
.. {directive}:: {version}
"""
),
),
],
ids=["reason&version", "version"],
)
def test_cls_has_sphinx_docstring(docstring, directive, reason, version, expected):
# The class:
class Foo(object):
pass
# with docstring:
Foo.__doc__ = docstring
# is decorated with:
decorator_factory = getattr(deprecated.sphinx, directive)
decorator = decorator_factory(reason=reason, version=version)
> Foo = decorator(Foo)
E TypeError: 'NoneType' object is not callable
tests/test_sphinx.py:148: TypeError
test_sphinx.py::test_has_sphinx_docstring[short_docstring-versionadded-reason&version]
test_sphinx.py::test_has_sphinx_docstring[short_docstring-versionadded-reason&version]
docstring = 'This function adds *x* and *y*.', directive = 'versionadded'
reason = 'A good reason', version = '1.2.0'
expected = '.. {directive}:: {version}\n {reason}\n'
@pytest.mark.parametrize(
"reason, version, expected",
[
(
'A good reason',
'1.2.0',
textwrap.dedent(
"""\
.. {directive}:: {version}
{reason}
"""
),
),
(
None,
'1.2.0',
textwrap.dedent(
"""\
.. {directive}:: {version}
"""
),
),
],
ids=["reason&version", "version"],
)
def test_has_sphinx_docstring(docstring, directive, reason, version, expected):
# The function:
def foo(x, y):
return x + y
# with docstring:
foo.__doc__ = docstring
# is decorated with:
decorator_factory = getattr(deprecated.sphinx, directive)
decorator = decorator_factory(reason=reason, version=version)
> foo = decorator(foo)
E TypeError: 'NoneType' object is not callable
tests/test_sphinx.py:81: TypeError
test_sphinx.py::test_has_sphinx_docstring[short_docstring-versionadded-version]
test_sphinx.py::test_has_sphinx_docstring[short_docstring-versionadded-version]
docstring = 'This function adds *x* and *y*.', directive = 'versionadded'
reason = None, version = '1.2.0', expected = '.. {directive}:: {version}\n'
@pytest.mark.parametrize(
"reason, version, expected",
[
(
'A good reason',
'1.2.0',
textwrap.dedent(
"""\
.. {directive}:: {version}
{reason}
"""
),
),
(
None,
'1.2.0',
textwrap.dedent(
"""\
.. {directive}:: {version}
"""
),
),
],
ids=["reason&version", "version"],
)
def test_has_sphinx_docstring(docstring, directive, reason, version, expected):
# The function:
def foo(x, y):
return x + y
# with docstring:
foo.__doc__ = docstring
# is decorated with:
decorator_factory = getattr(deprecated.sphinx, directive)
decorator = decorator_factory(reason=reason, version=version)
> foo = decorator(foo)
E TypeError: 'NoneType' object is not callable
tests/test_sphinx.py:81: TypeError
test_sphinx.py::test_cls_has_sphinx_docstring[short_docstring-versionadded-reason&version]
test_sphinx.py::test_cls_has_sphinx_docstring[short_docstring-versionadded-reason&version]
docstring = 'This function adds *x* and *y*.', directive = 'versionadded'
reason = 'A good reason', version = '1.2.0'
expected = '.. {directive}:: {version}\n {reason}\n'
@pytest.mark.skipif(
sys.version_info < (3, 3), reason="Classes should have mutable docstrings -- resolved in python 3.3"
)
@pytest.mark.parametrize(
"reason, version, expected",
[
(
'A good reason',
'1.2.0',
textwrap.dedent(
"""\
.. {directive}:: {version}
{reason}
"""
),
),
(
None,
'1.2.0',
textwrap.dedent(
"""\
.. {directive}:: {version}
"""
),
),
],
ids=["reason&version", "version"],
)
def test_cls_has_sphinx_docstring(docstring, directive, reason, version, expected):
# The class:
class Foo(object):
pass
# with docstring:
Foo.__doc__ = docstring
# is decorated with:
decorator_factory = getattr(deprecated.sphinx, directive)
decorator = decorator_factory(reason=reason, version=version)
> Foo = decorator(Foo)
E TypeError: 'NoneType' object is not callable
tests/test_sphinx.py:148: TypeError
test_sphinx.py::test_cls_has_sphinx_docstring[short_docstring-versionadded-version]
test_sphinx.py::test_cls_has_sphinx_docstring[short_docstring-versionadded-version]
docstring = 'This function adds *x* and *y*.', directive = 'versionadded'
reason = None, version = '1.2.0', expected = '.. {directive}:: {version}\n'
@pytest.mark.skipif(
sys.version_info < (3, 3), reason="Classes should have mutable docstrings -- resolved in python 3.3"
)
@pytest.mark.parametrize(
"reason, version, expected",
[
(
'A good reason',
'1.2.0',
textwrap.dedent(
"""\
.. {directive}:: {version}
{reason}
"""
),
),
(
None,
'1.2.0',
textwrap.dedent(
"""\
.. {directive}:: {version}
"""
),
),
],
ids=["reason&version", "version"],
)
def test_cls_has_sphinx_docstring(docstring, directive, reason, version, expected):
# The class:
class Foo(object):
pass
# with docstring:
Foo.__doc__ = docstring
# is decorated with:
decorator_factory = getattr(deprecated.sphinx, directive)
decorator = decorator_factory(reason=reason, version=version)
> Foo = decorator(Foo)
E TypeError: 'NoneType' object is not callable
tests/test_sphinx.py:148: TypeError
test_sphinx.py::test_has_sphinx_docstring[short_docstring-deprecated-reason&version]
test_sphinx.py::test_has_sphinx_docstring[short_docstring-deprecated-reason&version]
docstring = 'This function adds *x* and *y*.', directive = 'deprecated'
reason = 'A good reason', version = '1.2.0'
expected = '.. {directive}:: {version}\n {reason}\n'
@pytest.mark.parametrize(
"reason, version, expected",
[
(
'A good reason',
'1.2.0',
textwrap.dedent(
"""\
.. {directive}:: {version}
{reason}
"""
),
),
(
None,
'1.2.0',
textwrap.dedent(
"""\
.. {directive}:: {version}
"""
),
),
],
ids=["reason&version", "version"],
)
def test_has_sphinx_docstring(docstring, directive, reason, version, expected):
# The function:
def foo(x, y):
return x + y
# with docstring:
foo.__doc__ = docstring
# is decorated with:
decorator_factory = getattr(deprecated.sphinx, directive)
decorator = decorator_factory(reason=reason, version=version)
> foo = decorator(foo)
E TypeError: 'NoneType' object is not callable
tests/test_sphinx.py:81: TypeError
test_sphinx.py::test_has_sphinx_docstring[short_docstring-deprecated-version]
test_sphinx.py::test_has_sphinx_docstring[short_docstring-deprecated-version]
docstring = 'This function adds *x* and *y*.', directive = 'deprecated'
reason = None, version = '1.2.0', expected = '.. {directive}:: {version}\n'
@pytest.mark.parametrize(
"reason, version, expected",
[
(
'A good reason',
'1.2.0',
textwrap.dedent(
"""\
.. {directive}:: {version}
{reason}
"""
),
),
(
None,
'1.2.0',
textwrap.dedent(
"""\
.. {directive}:: {version}
"""
),
),
],
ids=["reason&version", "version"],
)
def test_has_sphinx_docstring(docstring, directive, reason, version, expected):
# The function:
def foo(x, y):
return x + y
# with docstring:
foo.__doc__ = docstring
# is decorated with:
decorator_factory = getattr(deprecated.sphinx, directive)
decorator = decorator_factory(reason=reason, version=version)
> foo = decorator(foo)
E TypeError: 'NoneType' object is not callable
tests/test_sphinx.py:81: TypeError
test_sphinx.py::test_cls_has_sphinx_docstring[short_docstring-deprecated-reason&version]
test_sphinx.py::test_cls_has_sphinx_docstring[short_docstring-deprecated-reason&version]
docstring = 'This function adds *x* and *y*.', directive = 'deprecated'
reason = 'A good reason', version = '1.2.0'
expected = '.. {directive}:: {version}\n {reason}\n'
@pytest.mark.skipif(
sys.version_info < (3, 3), reason="Classes should have mutable docstrings -- resolved in python 3.3"
)
@pytest.mark.parametrize(
"reason, version, expected",
[
(
'A good reason',
'1.2.0',
textwrap.dedent(
"""\
.. {directive}:: {version}
{reason}
"""
),
),
(
None,
'1.2.0',
textwrap.dedent(
"""\
.. {directive}:: {version}
"""
),
),
],
ids=["reason&version", "version"],
)
def test_cls_has_sphinx_docstring(docstring, directive, reason, version, expected):
# The class:
class Foo(object):
pass
# with docstring:
Foo.__doc__ = docstring
# is decorated with:
decorator_factory = getattr(deprecated.sphinx, directive)
decorator = decorator_factory(reason=reason, version=version)
> Foo = decorator(Foo)
E TypeError: 'NoneType' object is not callable
tests/test_sphinx.py:148: TypeError
test_sphinx.py::test_cls_has_sphinx_docstring[short_docstring-deprecated-version]
test_sphinx.py::test_cls_has_sphinx_docstring[short_docstring-deprecated-version]
docstring = 'This function adds *x* and *y*.', directive = 'deprecated'
reason = None, version = '1.2.0', expected = '.. {directive}:: {version}\n'
@pytest.mark.skipif(
sys.version_info < (3, 3), reason="Classes should have mutable docstrings -- resolved in python 3.3"
)
@pytest.mark.parametrize(
"reason, version, expected",
[
(
'A good reason',
'1.2.0',
textwrap.dedent(
"""\
.. {directive}:: {version}
{reason}
"""
),
),
(
None,
'1.2.0',
textwrap.dedent(
"""\
.. {directive}:: {version}
"""
),
),
],
ids=["reason&version", "version"],
)
def test_cls_has_sphinx_docstring(docstring, directive, reason, version, expected):
# The class:
class Foo(object):
pass
# with docstring:
Foo.__doc__ = docstring
# is decorated with:
decorator_factory = getattr(deprecated.sphinx, directive)
decorator = decorator_factory(reason=reason, version=version)
> Foo = decorator(Foo)
E TypeError: 'NoneType' object is not callable
tests/test_sphinx.py:148: TypeError
test_sphinx.py::test_has_sphinx_docstring[no_docstring-deprecated-reason&version]
test_sphinx.py::test_has_sphinx_docstring[no_docstring-deprecated-reason&version]
docstring = None, directive = 'deprecated', reason = 'A good reason'
version = '1.2.0', expected = '.. {directive}:: {version}\n {reason}\n'
@pytest.mark.parametrize(
"reason, version, expected",
[
(
'A good reason',
'1.2.0',
textwrap.dedent(
"""\
.. {directive}:: {version}
{reason}
"""
),
),
(
None,
'1.2.0',
textwrap.dedent(
"""\
.. {directive}:: {version}
"""
),
),
],
ids=["reason&version", "version"],
)
def test_has_sphinx_docstring(docstring, directive, reason, version, expected):
# The function:
def foo(x, y):
return x + y
# with docstring:
foo.__doc__ = docstring
# is decorated with:
decorator_factory = getattr(deprecated.sphinx, directive)
decorator = decorator_factory(reason=reason, version=version)
> foo = decorator(foo)
E TypeError: 'NoneType' object is not callable
tests/test_sphinx.py:81: TypeError
test_sphinx.py::test_has_sphinx_docstring[no_docstring-deprecated-version]
test_sphinx.py::test_has_sphinx_docstring[no_docstring-deprecated-version]
docstring = None, directive = 'deprecated', reason = None, version = '1.2.0'
expected = '.. {directive}:: {version}\n'
@pytest.mark.parametrize(
"reason, version, expected",
[
(
'A good reason',
'1.2.0',
textwrap.dedent(
"""\
.. {directive}:: {version}
{reason}
"""
),
),
(
None,
'1.2.0',
textwrap.dedent(
"""\
.. {directive}:: {version}
"""
),
),
],
ids=["reason&version", "version"],
)
def test_has_sphinx_docstring(docstring, directive, reason, version, expected):
# The function:
def foo(x, y):
return x + y
# with docstring:
foo.__doc__ = docstring
# is decorated with:
decorator_factory = getattr(deprecated.sphinx, directive)
decorator = decorator_factory(reason=reason, version=version)
> foo = decorator(foo)
E TypeError: 'NoneType' object is not callable
tests/test_sphinx.py:81: TypeError
test_sphinx.py::test_cls_has_sphinx_docstring[no_docstring-deprecated-reason&version]
test_sphinx.py::test_cls_has_sphinx_docstring[no_docstring-deprecated-reason&version]
docstring = None, directive = 'deprecated', reason = 'A good reason'
version = '1.2.0', expected = '.. {directive}:: {version}\n {reason}\n'
@pytest.mark.skipif(
sys.version_info < (3, 3), reason="Classes should have mutable docstrings -- resolved in python 3.3"
)
@pytest.mark.parametrize(
"reason, version, expected",
[
(
'A good reason',
'1.2.0',
textwrap.dedent(
"""\
.. {directive}:: {version}
{reason}
"""
),
),
(
None,
'1.2.0',
textwrap.dedent(
"""\
.. {directive}:: {version}
"""
),
),
],
ids=["reason&version", "version"],
)
def test_cls_has_sphinx_docstring(docstring, directive, reason, version, expected):
# The class:
class Foo(object):
pass
# with docstring:
Foo.__doc__ = docstring
# is decorated with:
decorator_factory = getattr(deprecated.sphinx, directive)
decorator = decorator_factory(reason=reason, version=version)
> Foo = decorator(Foo)
E TypeError: 'NoneType' object is not callable
tests/test_sphinx.py:148: TypeError
test_sphinx.py::test_cls_has_sphinx_docstring[no_docstring-deprecated-version]
test_sphinx.py::test_cls_has_sphinx_docstring[no_docstring-deprecated-version]
docstring = None, directive = 'deprecated', reason = None, version = '1.2.0'
expected = '.. {directive}:: {version}\n'
@pytest.mark.skipif(
sys.version_info < (3, 3), reason="Classes should have mutable docstrings -- resolved in python 3.3"
)
@pytest.mark.parametrize(
"reason, version, expected",
[
(
'A good reason',
'1.2.0',
textwrap.dedent(
"""\
.. {directive}:: {version}
{reason}
"""
),
),
(
None,
'1.2.0',
textwrap.dedent(
"""\
.. {directive}:: {version}
"""
),
),
],
ids=["reason&version", "version"],
)
def test_cls_has_sphinx_docstring(docstring, directive, reason, version, expected):
# The class:
class Foo(object):
pass
# with docstring:
Foo.__doc__ = docstring
# is decorated with:
decorator_factory = getattr(deprecated.sphinx, directive)
decorator = decorator_factory(reason=reason, version=version)
> Foo = decorator(Foo)
E TypeError: 'NoneType' object is not callable
tests/test_sphinx.py:148: TypeError
test_sphinx.py::test_has_sphinx_docstring[D213_long_docstring-deprecated-reason&version]
test_sphinx.py::test_has_sphinx_docstring[D213_long_docstring-deprecated-reason&version]
docstring = '\n This function adds *x* and *y*.\n\n :param x: number *x*\n :param y: number *y*\n :return: sum = *x* + *y*\n '
directive = 'deprecated', reason = 'A good reason', version = '1.2.0'
expected = '.. {directive}:: {version}\n {reason}\n'
@pytest.mark.parametrize(
"reason, version, expected",
[
(
'A good reason',
'1.2.0',
textwrap.dedent(
"""\
.. {directive}:: {version}
{reason}
"""
),
),
(
None,
'1.2.0',
textwrap.dedent(
"""\
.. {directive}:: {version}
"""
),
),
],
ids=["reason&version", "version"],
)
def test_has_sphinx_docstring(docstring, directive, reason, version, expected):
# The function:
def foo(x, y):
return x + y
# with docstring:
foo.__doc__ = docstring
# is decorated with:
decorator_factory = getattr(deprecated.sphinx, directive)
decorator = decorator_factory(reason=reason, version=version)
> foo = decorator(foo)
E TypeError: 'NoneType' object is not callable
tests/test_sphinx.py:81: TypeError
test_sphinx.py::test_has_sphinx_docstring[D213_long_docstring-deprecated-version]
test_sphinx.py::test_has_sphinx_docstring[D213_long_docstring-deprecated-version]
docstring = '\n This function adds *x* and *y*.\n\n :param x: number *x*\n :param y: number *y*\n :return: sum = *x* + *y*\n '
directive = 'deprecated', reason = None, version = '1.2.0'
expected = '.. {directive}:: {version}\n'
@pytest.mark.parametrize(
"reason, version, expected",
[
(
'A good reason',
'1.2.0',
textwrap.dedent(
"""\
.. {directive}:: {version}
{reason}
"""
),
),
(
None,
'1.2.0',
textwrap.dedent(
"""\
.. {directive}:: {version}
"""
),
),
],
ids=["reason&version", "version"],
)
def test_has_sphinx_docstring(docstring, directive, reason, version, expected):
# The function:
def foo(x, y):
return x + y
# with docstring:
foo.__doc__ = docstring
# is decorated with:
decorator_factory = getattr(deprecated.sphinx, directive)
decorator = decorator_factory(reason=reason, version=version)
> foo = decorator(foo)
E TypeError: 'NoneType' object is not callable
tests/test_sphinx.py:81: TypeError
test_sphinx.py::test_cls_has_sphinx_docstring[D213_long_docstring-deprecated-reason&version]
test_sphinx.py::test_cls_has_sphinx_docstring[D213_long_docstring-deprecated-reason&version]
docstring = '\n This function adds *x* and *y*.\n\n :param x: number *x*\n :param y: number *y*\n :return: sum = *x* + *y*\n '
directive = 'deprecated', reason = 'A good reason', version = '1.2.0'
expected = '.. {directive}:: {version}\n {reason}\n'
@pytest.mark.skipif(
sys.version_info < (3, 3), reason="Classes should have mutable docstrings -- resolved in python 3.3"
)
@pytest.mark.parametrize(
"reason, version, expected",
[
(
'A good reason',
'1.2.0',
textwrap.dedent(
"""\
.. {directive}:: {version}
{reason}
"""
),
),
(
None,
'1.2.0',
textwrap.dedent(
"""\
.. {directive}:: {version}
"""
),
),
],
ids=["reason&version", "version"],
)
def test_cls_has_sphinx_docstring(docstring, directive, reason, version, expected):
# The class:
class Foo(object):
pass
# with docstring:
Foo.__doc__ = docstring
# is decorated with:
decorator_factory = getattr(deprecated.sphinx, directive)
decorator = decorator_factory(reason=reason, version=version)
> Foo = decorator(Foo)
E TypeError: 'NoneType' object is not callable
tests/test_sphinx.py:148: TypeError
test_sphinx.py::test_cls_has_sphinx_docstring[D213_long_docstring-deprecated-version]
test_sphinx.py::test_cls_has_sphinx_docstring[D213_long_docstring-deprecated-version]
docstring = '\n This function adds *x* and *y*.\n\n :param x: number *x*\n :param y: number *y*\n :return: sum = *x* + *y*\n '
directive = 'deprecated', reason = None, version = '1.2.0'
expected = '.. {directive}:: {version}\n'
@pytest.mark.skipif(
sys.version_info < (3, 3), reason="Classes should have mutable docstrings -- resolved in python 3.3"
)
@pytest.mark.parametrize(
"reason, version, expected",
[
(
'A good reason',
'1.2.0',
textwrap.dedent(
"""\
.. {directive}:: {version}
{reason}
"""
),
),
(
None,
'1.2.0',
textwrap.dedent(
"""\
.. {directive}:: {version}
"""
),
),
],
ids=["reason&version", "version"],
)
def test_cls_has_sphinx_docstring(docstring, directive, reason, version, expected):
# The class:
class Foo(object):
pass
# with docstring:
Foo.__doc__ = docstring
# is decorated with:
decorator_factory = getattr(deprecated.sphinx, directive)
decorator = decorator_factory(reason=reason, version=version)
> Foo = decorator(Foo)
E TypeError: 'NoneType' object is not callable
tests/test_sphinx.py:148: TypeError
test_sphinx.py::test_has_sphinx_docstring[D213_long_docstring-versionchanged-reason&version]
test_sphinx.py::test_has_sphinx_docstring[D213_long_docstring-versionchanged-reason&version]
docstring = '\n This function adds *x* and *y*.\n\n :param x: number *x*\n :param y: number *y*\n :return: sum = *x* + *y*\n '
directive = 'versionchanged', reason = 'A good reason', version = '1.2.0'
expected = '.. {directive}:: {version}\n {reason}\n'
@pytest.mark.parametrize(
"reason, version, expected",
[
(
'A good reason',
'1.2.0',
textwrap.dedent(
"""\
.. {directive}:: {version}
{reason}
"""
),
),
(
None,
'1.2.0',
textwrap.dedent(
"""\
.. {directive}:: {version}
"""
),
),
],
ids=["reason&version", "version"],
)
def test_has_sphinx_docstring(docstring, directive, reason, version, expected):
# The function:
def foo(x, y):
return x + y
# with docstring:
foo.__doc__ = docstring
# is decorated with:
decorator_factory = getattr(deprecated.sphinx, directive)
decorator = decorator_factory(reason=reason, version=version)
> foo = decorator(foo)
E TypeError: 'NoneType' object is not callable
tests/test_sphinx.py:81: TypeError
test_sphinx.py::test_has_sphinx_docstring[D213_long_docstring-versionchanged-version]
test_sphinx.py::test_has_sphinx_docstring[D213_long_docstring-versionchanged-version]
docstring = '\n This function adds *x* and *y*.\n\n :param x: number *x*\n :param y: number *y*\n :return: sum = *x* + *y*\n '
directive = 'versionchanged', reason = None, version = '1.2.0'
expected = '.. {directive}:: {version}\n'
@pytest.mark.parametrize(
"reason, version, expected",
[
(
'A good reason',
'1.2.0',
textwrap.dedent(
"""\
.. {directive}:: {version}
{reason}
"""
),
),
(
None,
'1.2.0',
textwrap.dedent(
"""\
.. {directive}:: {version}
"""
),
),
],
ids=["reason&version", "version"],
)
def test_has_sphinx_docstring(docstring, directive, reason, version, expected):
# The function:
def foo(x, y):
return x + y
# with docstring:
foo.__doc__ = docstring
# is decorated with:
decorator_factory = getattr(deprecated.sphinx, directive)
decorator = decorator_factory(reason=reason, version=version)
> foo = decorator(foo)
E TypeError: 'NoneType' object is not callable
tests/test_sphinx.py:81: TypeError
test_sphinx.py::test_cls_has_sphinx_docstring[D213_long_docstring-versionchanged-reason&version]
test_sphinx.py::test_cls_has_sphinx_docstring[D213_long_docstring-versionchanged-reason&version]
docstring = '\n This function adds *x* and *y*.\n\n :param x: number *x*\n :param y: number *y*\n :return: sum = *x* + *y*\n '
directive = 'versionchanged', reason = 'A good reason', version = '1.2.0'
expected = '.. {directive}:: {version}\n {reason}\n'
@pytest.mark.skipif(
sys.version_info < (3, 3), reason="Classes should have mutable docstrings -- resolved in python 3.3"
)
@pytest.mark.parametrize(
"reason, version, expected",
[
(
'A good reason',
'1.2.0',
textwrap.dedent(
"""\
.. {directive}:: {version}
{reason}
"""
),
),
(
None,
'1.2.0',
textwrap.dedent(
"""\
.. {directive}:: {version}
"""
),
),
],
ids=["reason&version", "version"],
)
def test_cls_has_sphinx_docstring(docstring, directive, reason, version, expected):
# The class:
class Foo(object):
pass
# with docstring:
Foo.__doc__ = docstring
# is decorated with:
decorator_factory = getattr(deprecated.sphinx, directive)
decorator = decorator_factory(reason=reason, version=version)
> Foo = decorator(Foo)
E TypeError: 'NoneType' object is not callable
tests/test_sphinx.py:148: TypeError
test_sphinx.py::test_cls_has_sphinx_docstring[D213_long_docstring-versionchanged-version]
test_sphinx.py::test_cls_has_sphinx_docstring[D213_long_docstring-versionchanged-version]
docstring = '\n This function adds *x* and *y*.\n\n :param x: number *x*\n :param y: number *y*\n :return: sum = *x* + *y*\n '
directive = 'versionchanged', reason = None, version = '1.2.0'
expected = '.. {directive}:: {version}\n'
@pytest.mark.skipif(
sys.version_info < (3, 3), reason="Classes should have mutable docstrings -- resolved in python 3.3"
)
@pytest.mark.parametrize(
"reason, version, expected",
[
(
'A good reason',
'1.2.0',
textwrap.dedent(
"""\
.. {directive}:: {version}
{reason}
"""
),
),
(
None,
'1.2.0',
textwrap.dedent(
"""\
.. {directive}:: {version}
"""
),
),
],
ids=["reason&version", "version"],
)
def test_cls_has_sphinx_docstring(docstring, directive, reason, version, expected):
# The class:
class Foo(object):
pass
# with docstring:
Foo.__doc__ = docstring
# is decorated with:
decorator_factory = getattr(deprecated.sphinx, directive)
decorator = decorator_factory(reason=reason, version=version)
> Foo = decorator(Foo)
E TypeError: 'NoneType' object is not callable
tests/test_sphinx.py:148: TypeError
test_sphinx.py::test_has_sphinx_docstring[D213_long_docstring-versionadded-reason&version]
test_sphinx.py::test_has_sphinx_docstring[D213_long_docstring-versionadded-reason&version]
docstring = '\n This function adds *x* and *y*.\n\n :param x: number *x*\n :param y: number *y*\n :return: sum = *x* + *y*\n '
directive = 'versionadded', reason = 'A good reason', version = '1.2.0'
expected = '.. {directive}:: {version}\n {reason}\n'
@pytest.mark.parametrize(
"reason, version, expected",
[
(
'A good reason',
'1.2.0',
textwrap.dedent(
"""\
.. {directive}:: {version}
{reason}
"""
),
),
(
None,
'1.2.0',
textwrap.dedent(
"""\
.. {directive}:: {version}
"""
),
),
],
ids=["reason&version", "version"],
)
def test_has_sphinx_docstring(docstring, directive, reason, version, expected):
# The function:
def foo(x, y):
return x + y
# with docstring:
foo.__doc__ = docstring
# is decorated with:
decorator_factory = getattr(deprecated.sphinx, directive)
decorator = decorator_factory(reason=reason, version=version)
> foo = decorator(foo)
E TypeError: 'NoneType' object is not callable
tests/test_sphinx.py:81: TypeError
test_sphinx.py::test_has_sphinx_docstring[D213_long_docstring-versionadded-version]
test_sphinx.py::test_has_sphinx_docstring[D213_long_docstring-versionadded-version]
docstring = '\n This function adds *x* and *y*.\n\n :param x: number *x*\n :param y: number *y*\n :return: sum = *x* + *y*\n '
directive = 'versionadded', reason = None, version = '1.2.0'
expected = '.. {directive}:: {version}\n'
@pytest.mark.parametrize(
"reason, version, expected",
[
(
'A good reason',
'1.2.0',
textwrap.dedent(
"""\
.. {directive}:: {version}
{reason}
"""
),
),
(
None,
'1.2.0',
textwrap.dedent(
"""\
.. {directive}:: {version}
"""
),
),
],
ids=["reason&version", "version"],
)
def test_has_sphinx_docstring(docstring, directive, reason, version, expected):
# The function:
def foo(x, y):
return x + y
# with docstring:
foo.__doc__ = docstring
# is decorated with:
decorator_factory = getattr(deprecated.sphinx, directive)
decorator = decorator_factory(reason=reason, version=version)
> foo = decorator(foo)
E TypeError: 'NoneType' object is not callable
tests/test_sphinx.py:81: TypeError
test_sphinx.py::test_cls_has_sphinx_docstring[D213_long_docstring-versionadded-reason&version]
test_sphinx.py::test_cls_has_sphinx_docstring[D213_long_docstring-versionadded-reason&version]
docstring = '\n This function adds *x* and *y*.\n\n :param x: number *x*\n :param y: number *y*\n :return: sum = *x* + *y*\n '
directive = 'versionadded', reason = 'A good reason', version = '1.2.0'
expected = '.. {directive}:: {version}\n {reason}\n'
@pytest.mark.skipif(
sys.version_info < (3, 3), reason="Classes should have mutable docstrings -- resolved in python 3.3"
)
@pytest.mark.parametrize(
"reason, version, expected",
[
(
'A good reason',
'1.2.0',
textwrap.dedent(
"""\
.. {directive}:: {version}
{reason}
"""
),
),
(
None,
'1.2.0',
textwrap.dedent(
"""\
.. {directive}:: {version}
"""
),
),
],
ids=["reason&version", "version"],
)
def test_cls_has_sphinx_docstring(docstring, directive, reason, version, expected):
# The class:
class Foo(object):
pass
# with docstring:
Foo.__doc__ = docstring
# is decorated with:
decorator_factory = getattr(deprecated.sphinx, directive)
decorator = decorator_factory(reason=reason, version=version)
> Foo = decorator(Foo)
E TypeError: 'NoneType' object is not callable
tests/test_sphinx.py:148: TypeError
test_sphinx.py::test_cls_has_sphinx_docstring[D213_long_docstring-versionadded-version]
test_sphinx.py::test_cls_has_sphinx_docstring[D213_long_docstring-versionadded-version]
docstring = '\n This function adds *x* and *y*.\n\n :param x: number *x*\n :param y: number *y*\n :return: sum = *x* + *y*\n '
directive = 'versionadded', reason = None, version = '1.2.0'
expected = '.. {directive}:: {version}\n'
@pytest.mark.skipif(
sys.version_info < (3, 3), reason="Classes should have mutable docstrings -- resolved in python 3.3"
)
@pytest.mark.parametrize(
"reason, version, expected",
[
(
'A good reason',
'1.2.0',
textwrap.dedent(
"""\
.. {directive}:: {version}
{reason}
"""
),
),
(
None,
'1.2.0',
textwrap.dedent(
"""\
.. {directive}:: {version}
"""
),
),
],
ids=["reason&version", "version"],
)
def test_cls_has_sphinx_docstring(docstring, directive, reason, version, expected):
# The class:
class Foo(object):
pass
# with docstring:
Foo.__doc__ = docstring
# is decorated with:
decorator_factory = getattr(deprecated.sphinx, directive)
decorator = decorator_factory(reason=reason, version=version)
> Foo = decorator(Foo)
E TypeError: 'NoneType' object is not callable
tests/test_sphinx.py:148: TypeError
test_sphinx.py::test_has_sphinx_docstring[D212_long_docstring-deprecated-reason&version]
test_sphinx.py::test_has_sphinx_docstring[D212_long_docstring-deprecated-reason&version]
docstring = 'This function adds *x* and *y*.\n\n :param x: number *x*\n :param y: number *y*\n :return: sum = *x* + *y*\n '
directive = 'deprecated', reason = 'A good reason', version = '1.2.0'
expected = '.. {directive}:: {version}\n {reason}\n'
@pytest.mark.parametrize(
"reason, version, expected",
[
(
'A good reason',
'1.2.0',
textwrap.dedent(
"""\
.. {directive}:: {version}
{reason}
"""
),
),
(
None,
'1.2.0',
textwrap.dedent(
"""\
.. {directive}:: {version}
"""
),
),
],
ids=["reason&version", "version"],
)
def test_has_sphinx_docstring(docstring, directive, reason, version, expected):
# The function:
def foo(x, y):
return x + y
# with docstring:
foo.__doc__ = docstring
# is decorated with:
decorator_factory = getattr(deprecated.sphinx, directive)
decorator = decorator_factory(reason=reason, version=version)
> foo = decorator(foo)
E TypeError: 'NoneType' object is not callable
tests/test_sphinx.py:81: TypeError
test_sphinx.py::test_has_sphinx_docstring[D212_long_docstring-deprecated-version]
test_sphinx.py::test_has_sphinx_docstring[D212_long_docstring-deprecated-version]
docstring = 'This function adds *x* and *y*.\n\n :param x: number *x*\n :param y: number *y*\n :return: sum = *x* + *y*\n '
directive = 'deprecated', reason = None, version = '1.2.0'
expected = '.. {directive}:: {version}\n'
@pytest.mark.parametrize(
"reason, version, expected",
[
(
'A good reason',
'1.2.0',
textwrap.dedent(
"""\
.. {directive}:: {version}
{reason}
"""
),
),
(
None,
'1.2.0',
textwrap.dedent(
"""\
.. {directive}:: {version}
"""
),
),
],
ids=["reason&version", "version"],
)
def test_has_sphinx_docstring(docstring, directive, reason, version, expected):
# The function:
def foo(x, y):
return x + y
# with docstring:
foo.__doc__ = docstring
# is decorated with:
decorator_factory = getattr(deprecated.sphinx, directive)
decorator = decorator_factory(reason=reason, version=version)
> foo = decorator(foo)
E TypeError: 'NoneType' object is not callable
tests/test_sphinx.py:81: TypeError
test_sphinx.py::test_cls_has_sphinx_docstring[D212_long_docstring-deprecated-reason&version]
test_sphinx.py::test_cls_has_sphinx_docstring[D212_long_docstring-deprecated-reason&version]
docstring = 'This function adds *x* and *y*.\n\n :param x: number *x*\n :param y: number *y*\n :return: sum = *x* + *y*\n '
directive = 'deprecated', reason = 'A good reason', version = '1.2.0'
expected = '.. {directive}:: {version}\n {reason}\n'
@pytest.mark.skipif(
sys.version_info < (3, 3), reason="Classes should have mutable docstrings -- resolved in python 3.3"
)
@pytest.mark.parametrize(
"reason, version, expected",
[
(
'A good reason',
'1.2.0',
textwrap.dedent(
"""\
.. {directive}:: {version}
{reason}
"""
),
),
(
None,
'1.2.0',
textwrap.dedent(
"""\
.. {directive}:: {version}
"""
),
),
],
ids=["reason&version", "version"],
)
def test_cls_has_sphinx_docstring(docstring, directive, reason, version, expected):
# The class:
class Foo(object):
pass
# with docstring:
Foo.__doc__ = docstring
# is decorated with:
decorator_factory = getattr(deprecated.sphinx, directive)
decorator = decorator_factory(reason=reason, version=version)
> Foo = decorator(Foo)
E TypeError: 'NoneType' object is not callable
tests/test_sphinx.py:148: TypeError
test_sphinx.py::test_cls_has_sphinx_docstring[D212_long_docstring-deprecated-version]
test_sphinx.py::test_cls_has_sphinx_docstring[D212_long_docstring-deprecated-version]
docstring = 'This function adds *x* and *y*.\n\n :param x: number *x*\n :param y: number *y*\n :return: sum = *x* + *y*\n '
directive = 'deprecated', reason = None, version = '1.2.0'
expected = '.. {directive}:: {version}\n'
@pytest.mark.skipif(
sys.version_info < (3, 3), reason="Classes should have mutable docstrings -- resolved in python 3.3"
)
@pytest.mark.parametrize(
"reason, version, expected",
[
(
'A good reason',
'1.2.0',
textwrap.dedent(
"""\
.. {directive}:: {version}
{reason}
"""
),
),
(
None,
'1.2.0',
textwrap.dedent(
"""\
.. {directive}:: {version}
"""
),
),
],
ids=["reason&version", "version"],
)
def test_cls_has_sphinx_docstring(docstring, directive, reason, version, expected):
# The class:
class Foo(object):
pass
# with docstring:
Foo.__doc__ = docstring
# is decorated with:
decorator_factory = getattr(deprecated.sphinx, directive)
decorator = decorator_factory(reason=reason, version=version)
> Foo = decorator(Foo)
E TypeError: 'NoneType' object is not callable
tests/test_sphinx.py:148: TypeError
test_sphinx.py::test_has_sphinx_docstring[D212_long_docstring-versionchanged-reason&version]
test_sphinx.py::test_has_sphinx_docstring[D212_long_docstring-versionchanged-reason&version]
docstring = 'This function adds *x* and *y*.\n\n :param x: number *x*\n :param y: number *y*\n :return: sum = *x* + *y*\n '
directive = 'versionchanged', reason = 'A good reason', version = '1.2.0'
expected = '.. {directive}:: {version}\n {reason}\n'
@pytest.mark.parametrize(
"reason, version, expected",
[
(
'A good reason',
'1.2.0',
textwrap.dedent(
"""\
.. {directive}:: {version}
{reason}
"""
),
),
(
None,
'1.2.0',
textwrap.dedent(
"""\
.. {directive}:: {version}
"""
),
),
],
ids=["reason&version", "version"],
)
def test_has_sphinx_docstring(docstring, directive, reason, version, expected):
# The function:
def foo(x, y):
return x + y
# with docstring:
foo.__doc__ = docstring
# is decorated with:
decorator_factory = getattr(deprecated.sphinx, directive)
decorator = decorator_factory(reason=reason, version=version)
> foo = decorator(foo)
E TypeError: 'NoneType' object is not callable
tests/test_sphinx.py:81: TypeError
test_sphinx.py::test_has_sphinx_docstring[D212_long_docstring-versionchanged-version]
test_sphinx.py::test_has_sphinx_docstring[D212_long_docstring-versionchanged-version]
docstring = 'This function adds *x* and *y*.\n\n :param x: number *x*\n :param y: number *y*\n :return: sum = *x* + *y*\n '
directive = 'versionchanged', reason = None, version = '1.2.0'
expected = '.. {directive}:: {version}\n'
@pytest.mark.parametrize(
"reason, version, expected",
[
(
'A good reason',
'1.2.0',
textwrap.dedent(
"""\
.. {directive}:: {version}
{reason}
"""
),
),
(
None,
'1.2.0',
textwrap.dedent(
"""\
.. {directive}:: {version}
"""
),
),
],
ids=["reason&version", "version"],
)
def test_has_sphinx_docstring(docstring, directive, reason, version, expected):
# The function:
def foo(x, y):
return x + y
# with docstring:
foo.__doc__ = docstring
# is decorated with:
decorator_factory = getattr(deprecated.sphinx, directive)
decorator = decorator_factory(reason=reason, version=version)
> foo = decorator(foo)
E TypeError: 'NoneType' object is not callable
tests/test_sphinx.py:81: TypeError
test_sphinx.py::test_cls_has_sphinx_docstring[D212_long_docstring-versionchanged-reason&version]
test_sphinx.py::test_cls_has_sphinx_docstring[D212_long_docstring-versionchanged-reason&version]
docstring = 'This function adds *x* and *y*.\n\n :param x: number *x*\n :param y: number *y*\n :return: sum = *x* + *y*\n '
directive = 'versionchanged', reason = 'A good reason', version = '1.2.0'
expected = '.. {directive}:: {version}\n {reason}\n'
@pytest.mark.skipif(
sys.version_info < (3, 3), reason="Classes should have mutable docstrings -- resolved in python 3.3"
)
@pytest.mark.parametrize(
"reason, version, expected",
[
(
'A good reason',
'1.2.0',
textwrap.dedent(
"""\
.. {directive}:: {version}
{reason}
"""
),
),
(
None,
'1.2.0',
textwrap.dedent(
"""\
.. {directive}:: {version}
"""
),
),
],
ids=["reason&version", "version"],
)
def test_cls_has_sphinx_docstring(docstring, directive, reason, version, expected):
# The class:
class Foo(object):
pass
# with docstring:
Foo.__doc__ = docstring
# is decorated with:
decorator_factory = getattr(deprecated.sphinx, directive)
decorator = decorator_factory(reason=reason, version=version)
> Foo = decorator(Foo)
E TypeError: 'NoneType' object is not callable
tests/test_sphinx.py:148: TypeError
test_sphinx.py::test_cls_has_sphinx_docstring[D212_long_docstring-versionchanged-version]
test_sphinx.py::test_cls_has_sphinx_docstring[D212_long_docstring-versionchanged-version]
docstring = 'This function adds *x* and *y*.\n\n :param x: number *x*\n :param y: number *y*\n :return: sum = *x* + *y*\n '
directive = 'versionchanged', reason = None, version = '1.2.0'
expected = '.. {directive}:: {version}\n'
@pytest.mark.skipif(
sys.version_info < (3, 3), reason="Classes should have mutable docstrings -- resolved in python 3.3"
)
@pytest.mark.parametrize(
"reason, version, expected",
[
(
'A good reason',
'1.2.0',
textwrap.dedent(
"""\
.. {directive}:: {version}
{reason}
"""
),
),
(
None,
'1.2.0',
textwrap.dedent(
"""\
.. {directive}:: {version}
"""
),
),
],
ids=["reason&version", "version"],
)
def test_cls_has_sphinx_docstring(docstring, directive, reason, version, expected):
# The class:
class Foo(object):
pass
# with docstring:
Foo.__doc__ = docstring
# is decorated with:
decorator_factory = getattr(deprecated.sphinx, directive)
decorator = decorator_factory(reason=reason, version=version)
> Foo = decorator(Foo)
E TypeError: 'NoneType' object is not callable
tests/test_sphinx.py:148: TypeError
test_sphinx.py::test_has_sphinx_docstring[D212_long_docstring-versionadded-reason&version]
test_sphinx.py::test_has_sphinx_docstring[D212_long_docstring-versionadded-reason&version]
docstring = 'This function adds *x* and *y*.\n\n :param x: number *x*\n :param y: number *y*\n :return: sum = *x* + *y*\n '
directive = 'versionadded', reason = 'A good reason', version = '1.2.0'
expected = '.. {directive}:: {version}\n {reason}\n'
@pytest.mark.parametrize(
"reason, version, expected",
[
(
'A good reason',
'1.2.0',
textwrap.dedent(
"""\
.. {directive}:: {version}
{reason}
"""
),
),
(
None,
'1.2.0',
textwrap.dedent(
"""\
.. {directive}:: {version}
"""
),
),
],
ids=["reason&version", "version"],
)
def test_has_sphinx_docstring(docstring, directive, reason, version, expected):
# The function:
def foo(x, y):
return x + y
# with docstring:
foo.__doc__ = docstring
# is decorated with:
decorator_factory = getattr(deprecated.sphinx, directive)
decorator = decorator_factory(reason=reason, version=version)
> foo = decorator(foo)
E TypeError: 'NoneType' object is not callable
tests/test_sphinx.py:81: TypeError
test_sphinx.py::test_has_sphinx_docstring[D212_long_docstring-versionadded-version]
test_sphinx.py::test_has_sphinx_docstring[D212_long_docstring-versionadded-version]
docstring = 'This function adds *x* and *y*.\n\n :param x: number *x*\n :param y: number *y*\n :return: sum = *x* + *y*\n '
directive = 'versionadded', reason = None, version = '1.2.0'
expected = '.. {directive}:: {version}\n'
@pytest.mark.parametrize(
"reason, version, expected",
[
(
'A good reason',
'1.2.0',
textwrap.dedent(
"""\
.. {directive}:: {version}
{reason}
"""
),
),
(
None,
'1.2.0',
textwrap.dedent(
"""\
.. {directive}:: {version}
"""
),
),
],
ids=["reason&version", "version"],
)
def test_has_sphinx_docstring(docstring, directive, reason, version, expected):
# The function:
def foo(x, y):
return x + y
# with docstring:
foo.__doc__ = docstring
# is decorated with:
decorator_factory = getattr(deprecated.sphinx, directive)
decorator = decorator_factory(reason=reason, version=version)
> foo = decorator(foo)
E TypeError: 'NoneType' object is not callable
tests/test_sphinx.py:81: TypeError
test_sphinx.py::test_cls_has_sphinx_docstring[D212_long_docstring-versionadded-reason&version]
test_sphinx.py::test_cls_has_sphinx_docstring[D212_long_docstring-versionadded-reason&version]
docstring = 'This function adds *x* and *y*.\n\n :param x: number *x*\n :param y: number *y*\n :return: sum = *x* + *y*\n '
directive = 'versionadded', reason = 'A good reason', version = '1.2.0'
expected = '.. {directive}:: {version}\n {reason}\n'
@pytest.mark.skipif(
sys.version_info < (3, 3), reason="Classes should have mutable docstrings -- resolved in python 3.3"
)
@pytest.mark.parametrize(
"reason, version, expected",
[
(
'A good reason',
'1.2.0',
textwrap.dedent(
"""\
.. {directive}:: {version}
{reason}
"""
),
),
(
None,
'1.2.0',
textwrap.dedent(
"""\
.. {directive}:: {version}
"""
),
),
],
ids=["reason&version", "version"],
)
def test_cls_has_sphinx_docstring(docstring, directive, reason, version, expected):
# The class:
class Foo(object):
pass
# with docstring:
Foo.__doc__ = docstring
# is decorated with:
decorator_factory = getattr(deprecated.sphinx, directive)
decorator = decorator_factory(reason=reason, version=version)
> Foo = decorator(Foo)
E TypeError: 'NoneType' object is not callable
tests/test_sphinx.py:148: TypeError
test_sphinx.py::test_cls_has_sphinx_docstring[D212_long_docstring-versionadded-version]
test_sphinx.py::test_cls_has_sphinx_docstring[D212_long_docstring-versionadded-version]
docstring = 'This function adds *x* and *y*.\n\n :param x: number *x*\n :param y: number *y*\n :return: sum = *x* + *y*\n '
directive = 'versionadded', reason = None, version = '1.2.0'
expected = '.. {directive}:: {version}\n'
@pytest.mark.skipif(
sys.version_info < (3, 3), reason="Classes should have mutable docstrings -- resolved in python 3.3"
)
@pytest.mark.parametrize(
"reason, version, expected",
[
(
'A good reason',
'1.2.0',
textwrap.dedent(
"""\
.. {directive}:: {version}
{reason}
"""
),
),
(
None,
'1.2.0',
textwrap.dedent(
"""\
.. {directive}:: {version}
"""
),
),
],
ids=["reason&version", "version"],
)
def test_cls_has_sphinx_docstring(docstring, directive, reason, version, expected):
# The class:
class Foo(object):
pass
# with docstring:
Foo.__doc__ = docstring
# is decorated with:
decorator_factory = getattr(deprecated.sphinx, directive)
decorator = decorator_factory(reason=reason, version=version)
> Foo = decorator(Foo)
E TypeError: 'NoneType' object is not callable
tests/test_sphinx.py:148: TypeError
test_sphinx.py::test_sphinx_deprecated_function__warns[sphinx_deprecated_function0]
test_sphinx.py::test_sphinx_deprecated_function__warns[sphinx_deprecated_function0]
request = >
@pytest.fixture(scope="module", params=_PARAMS)
def sphinx_deprecated_function(request):
kwargs = request.param
@deprecated.sphinx.deprecated(**kwargs)
> def foo1():
E TypeError: 'NoneType' object is not callable
tests/test_sphinx.py:192: TypeError
test_sphinx.py::test_sphinx_deprecated_function__warns[sphinx_deprecated_function1]
test_sphinx.py::test_sphinx_deprecated_function__warns[sphinx_deprecated_function1]
request = >
@pytest.fixture(scope="module", params=_PARAMS)
def sphinx_deprecated_function(request):
kwargs = request.param
@deprecated.sphinx.deprecated(**kwargs)
> def foo1():
E TypeError: 'NoneType' object is not callable
tests/test_sphinx.py:192: TypeError
test_sphinx.py::test_sphinx_deprecated_function__warns[sphinx_deprecated_function2]
test_sphinx.py::test_sphinx_deprecated_function__warns[sphinx_deprecated_function2]
request = >
@pytest.fixture(scope="module", params=_PARAMS)
def sphinx_deprecated_function(request):
kwargs = request.param
@deprecated.sphinx.deprecated(**kwargs)
> def foo1():
E TypeError: 'NoneType' object is not callable
tests/test_sphinx.py:192: TypeError
test_sphinx.py::test_sphinx_deprecated_function__warns[sphinx_deprecated_function3]
test_sphinx.py::test_sphinx_deprecated_function__warns[sphinx_deprecated_function3]
request = >
@pytest.fixture(scope="module", params=_PARAMS)
def sphinx_deprecated_function(request):
kwargs = request.param
@deprecated.sphinx.deprecated(**kwargs)
> def foo1():
E TypeError: 'NoneType' object is not callable
tests/test_sphinx.py:192: TypeError
test_sphinx.py::test_sphinx_deprecated_class__warns[sphinx_deprecated_class0]
test_sphinx.py::test_sphinx_deprecated_class__warns[sphinx_deprecated_class0]
request = >
@pytest.fixture(scope="module", params=_PARAMS)
def sphinx_deprecated_class(request):
kwargs = request.param
@deprecated.sphinx.deprecated(**kwargs)
> class Foo2(object):
E TypeError: 'NoneType' object is not callable
tests/test_sphinx.py:203: TypeError
test_sphinx.py::test_sphinx_deprecated_class__warns[sphinx_deprecated_class1]
test_sphinx.py::test_sphinx_deprecated_class__warns[sphinx_deprecated_class1]
request = >
@pytest.fixture(scope="module", params=_PARAMS)
def sphinx_deprecated_class(request):
kwargs = request.param
@deprecated.sphinx.deprecated(**kwargs)
> class Foo2(object):
E TypeError: 'NoneType' object is not callable
tests/test_sphinx.py:203: TypeError
test_sphinx.py::test_sphinx_deprecated_class__warns[sphinx_deprecated_class2]
test_sphinx.py::test_sphinx_deprecated_class__warns[sphinx_deprecated_class2]
request = >
@pytest.fixture(scope="module", params=_PARAMS)
def sphinx_deprecated_class(request):
kwargs = request.param
@deprecated.sphinx.deprecated(**kwargs)
> class Foo2(object):
E TypeError: 'NoneType' object is not callable
tests/test_sphinx.py:203: TypeError
test_sphinx.py::test_sphinx_deprecated_class__warns[sphinx_deprecated_class3]
test_sphinx.py::test_sphinx_deprecated_class__warns[sphinx_deprecated_class3]
request = >
@pytest.fixture(scope="module", params=_PARAMS)
def sphinx_deprecated_class(request):
kwargs = request.param
@deprecated.sphinx.deprecated(**kwargs)
> class Foo2(object):
E TypeError: 'NoneType' object is not callable
tests/test_sphinx.py:203: TypeError
test_sphinx.py::test_sphinx_deprecated_method__warns[sphinx_deprecated_method0]
test_sphinx.py::test_sphinx_deprecated_method__warns[sphinx_deprecated_method0]
request = >
@pytest.fixture(scope="module", params=_PARAMS)
def sphinx_deprecated_method(request):
kwargs = request.param
> class Foo3(object):
tests/test_sphinx.py:213:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
class Foo3(object):
@deprecated.sphinx.deprecated(**kwargs)
> def foo3(self):
E TypeError: 'NoneType' object is not callable
tests/test_sphinx.py:215: TypeError
test_sphinx.py::test_sphinx_deprecated_method__warns[sphinx_deprecated_method1]
test_sphinx.py::test_sphinx_deprecated_method__warns[sphinx_deprecated_method1]
request = >
@pytest.fixture(scope="module", params=_PARAMS)
def sphinx_deprecated_method(request):
kwargs = request.param
> class Foo3(object):
tests/test_sphinx.py:213:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
class Foo3(object):
@deprecated.sphinx.deprecated(**kwargs)
> def foo3(self):
E TypeError: 'NoneType' object is not callable
tests/test_sphinx.py:215: TypeError
test_sphinx.py::test_sphinx_deprecated_method__warns[sphinx_deprecated_method2]
test_sphinx.py::test_sphinx_deprecated_method__warns[sphinx_deprecated_method2]
request = >
@pytest.fixture(scope="module", params=_PARAMS)
def sphinx_deprecated_method(request):
kwargs = request.param
> class Foo3(object):
tests/test_sphinx.py:213:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
class Foo3(object):
@deprecated.sphinx.deprecated(**kwargs)
> def foo3(self):
E TypeError: 'NoneType' object is not callable
tests/test_sphinx.py:215: TypeError
test_sphinx.py::test_sphinx_deprecated_method__warns[sphinx_deprecated_method3]
test_sphinx.py::test_sphinx_deprecated_method__warns[sphinx_deprecated_method3]
request = >
@pytest.fixture(scope="module", params=_PARAMS)
def sphinx_deprecated_method(request):
kwargs = request.param
> class Foo3(object):
tests/test_sphinx.py:213:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
class Foo3(object):
@deprecated.sphinx.deprecated(**kwargs)
> def foo3(self):
E TypeError: 'NoneType' object is not callable
tests/test_sphinx.py:215: TypeError
test_sphinx.py::test_sphinx_deprecated_static_method__warns[sphinx_deprecated_static_method0]
test_sphinx.py::test_sphinx_deprecated_static_method__warns[sphinx_deprecated_static_method0]
request = >
@pytest.fixture(scope="module", params=_PARAMS)
def sphinx_deprecated_static_method(request):
kwargs = request.param
> class Foo4(object):
tests/test_sphinx.py:225:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
class Foo4(object):
@staticmethod
@deprecated.sphinx.deprecated(**kwargs)
> def foo4():
E TypeError: 'NoneType' object is not callable
tests/test_sphinx.py:228: TypeError
test_sphinx.py::test_sphinx_deprecated_static_method__warns[sphinx_deprecated_static_method1]
test_sphinx.py::test_sphinx_deprecated_static_method__warns[sphinx_deprecated_static_method1]
request = >
@pytest.fixture(scope="module", params=_PARAMS)
def sphinx_deprecated_static_method(request):
kwargs = request.param
> class Foo4(object):
tests/test_sphinx.py:225:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
class Foo4(object):
@staticmethod
@deprecated.sphinx.deprecated(**kwargs)
> def foo4():
E TypeError: 'NoneType' object is not callable
tests/test_sphinx.py:228: TypeError
test_sphinx.py::test_sphinx_deprecated_static_method__warns[sphinx_deprecated_static_method2]
test_sphinx.py::test_sphinx_deprecated_static_method__warns[sphinx_deprecated_static_method2]
request = >
@pytest.fixture(scope="module", params=_PARAMS)
def sphinx_deprecated_static_method(request):
kwargs = request.param
> class Foo4(object):
tests/test_sphinx.py:225:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
class Foo4(object):
@staticmethod
@deprecated.sphinx.deprecated(**kwargs)
> def foo4():
E TypeError: 'NoneType' object is not callable
tests/test_sphinx.py:228: TypeError
test_sphinx.py::test_sphinx_deprecated_static_method__warns[sphinx_deprecated_static_method3]
test_sphinx.py::test_sphinx_deprecated_static_method__warns[sphinx_deprecated_static_method3]
request = >
@pytest.fixture(scope="module", params=_PARAMS)
def sphinx_deprecated_static_method(request):
kwargs = request.param
> class Foo4(object):
tests/test_sphinx.py:225:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
class Foo4(object):
@staticmethod
@deprecated.sphinx.deprecated(**kwargs)
> def foo4():
E TypeError: 'NoneType' object is not callable
tests/test_sphinx.py:228: TypeError
test_sphinx.py::test_sphinx_deprecated_class_method__warns[sphinx_deprecated_class_method0]
test_sphinx.py::test_sphinx_deprecated_class_method__warns[sphinx_deprecated_class_method0]
request = >
@pytest.fixture(scope="module", params=_PARAMS)
def sphinx_deprecated_class_method(request):
kwargs = request.param
> class Foo5(object):
tests/test_sphinx.py:238:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
class Foo5(object):
@classmethod
@deprecated.sphinx.deprecated(**kwargs)
> def foo5(cls):
E TypeError: 'NoneType' object is not callable
tests/test_sphinx.py:241: TypeError
test_sphinx.py::test_sphinx_deprecated_class_method__warns[sphinx_deprecated_class_method1]
test_sphinx.py::test_sphinx_deprecated_class_method__warns[sphinx_deprecated_class_method1]
request = >
@pytest.fixture(scope="module", params=_PARAMS)
def sphinx_deprecated_class_method(request):
kwargs = request.param
> class Foo5(object):
tests/test_sphinx.py:238:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
class Foo5(object):
@classmethod
@deprecated.sphinx.deprecated(**kwargs)
> def foo5(cls):
E TypeError: 'NoneType' object is not callable
tests/test_sphinx.py:241: TypeError
test_sphinx.py::test_sphinx_deprecated_class_method__warns[sphinx_deprecated_class_method2]
test_sphinx.py::test_sphinx_deprecated_class_method__warns[sphinx_deprecated_class_method2]
request = >
@pytest.fixture(scope="module", params=_PARAMS)
def sphinx_deprecated_class_method(request):
kwargs = request.param
> class Foo5(object):
tests/test_sphinx.py:238:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
class Foo5(object):
@classmethod
@deprecated.sphinx.deprecated(**kwargs)
> def foo5(cls):
E TypeError: 'NoneType' object is not callable
tests/test_sphinx.py:241: TypeError
test_sphinx.py::test_sphinx_deprecated_class_method__warns[sphinx_deprecated_class_method3]
test_sphinx.py::test_sphinx_deprecated_class_method__warns[sphinx_deprecated_class_method3]
request = >
@pytest.fixture(scope="module", params=_PARAMS)
def sphinx_deprecated_class_method(request):
kwargs = request.param
> class Foo5(object):
tests/test_sphinx.py:238:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
class Foo5(object):
@classmethod
@deprecated.sphinx.deprecated(**kwargs)
> def foo5(cls):
E TypeError: 'NoneType' object is not callable
tests/test_sphinx.py:241: TypeError
test_sphinx.py::test_warning_msg_has_reason
test_sphinx.py::test_warning_msg_has_reason
def test_warning_msg_has_reason():
reason = "Good reason"
@deprecated.sphinx.deprecated(version="4.5.6", reason=reason)
> def foo():
E TypeError: 'NoneType' object is not callable
tests/test_sphinx.py:325: TypeError
test_sphinx.py::test_warning_msg_has_version
test_sphinx.py::test_warning_msg_has_version
def test_warning_msg_has_version():
version = "1.2.3"
@deprecated.sphinx.deprecated(version=version)
> def foo():
E TypeError: 'NoneType' object is not callable
tests/test_sphinx.py:338: TypeError
test_sphinx.py::test_warning_is_ignored
test_sphinx.py::test_warning_is_ignored
def test_warning_is_ignored():
@deprecated.sphinx.deprecated(version="4.5.6", action='ignore')
> def foo():
E TypeError: 'NoneType' object is not callable
tests/test_sphinx.py:349: TypeError
test_sphinx.py::test_specific_warning_cls_is_used
test_sphinx.py::test_specific_warning_cls_is_used
def test_specific_warning_cls_is_used():
@deprecated.sphinx.deprecated(version="4.5.6", category=MyDeprecationWarning)
> def foo():
E TypeError: 'NoneType' object is not callable
tests/test_sphinx.py:359: TypeError
test_sphinx.py::test_sphinx_syntax_trimming[Use :function:bar
instead-Use bar
instead]
test_sphinx.py::test_sphinx_syntax_trimming[Use :function:`bar` instead-Use `bar` instead]
reason = 'Use :function:`bar` instead', expected = 'Use `bar` instead'
@pytest.mark.parametrize(
["reason", "expected"],
[
("Use :function:`bar` instead", "Use `bar` instead"),
("Use :py:func:`bar` instead", "Use `bar` instead"),
],
)
def test_sphinx_syntax_trimming(reason, expected):
@deprecated.sphinx.deprecated(version="4.5.6", reason=reason)
> def foo():
E TypeError: 'NoneType' object is not callable
tests/test_sphinx.py:384: TypeError
test_sphinx.py::test_sphinx_syntax_trimming[Use :py:func:bar
instead-Use bar
instead]
test_sphinx.py::test_sphinx_syntax_trimming[Use :py:func:`bar` instead-Use `bar` instead]
reason = 'Use :py:func:`bar` instead', expected = 'Use `bar` instead'
@pytest.mark.parametrize(
["reason", "expected"],
[
("Use :function:`bar` instead", "Use `bar` instead"),
("Use :py:func:`bar` instead", "Use `bar` instead"),
],
)
def test_sphinx_syntax_trimming(reason, expected):
@deprecated.sphinx.deprecated(version="4.5.6", reason=reason)
> def foo():
E TypeError: 'NoneType' object is not callable
tests/test_sphinx.py:384: TypeError
test_sphinx.py::test_get_deprecated_msg[Use :func:bar
instead-Use bar
instead]
test_sphinx.py::test_get_deprecated_msg[Use :func:`bar` instead-Use `bar` instead]
reason = 'Use :func:`bar` instead', expected = 'Use `bar` instead'
@pytest.mark.parametrize(
"reason, expected",
[
# classic examples using the default domain (Python)
("Use :func:`bar` instead", "Use `bar` instead"),
("Use :function:`bar` instead", "Use `bar` instead"),
("Use :class:`Baz` instead", "Use `Baz` instead"),
("Use :exc:`Baz` instead", "Use `Baz` instead"),
("Use :exception:`Baz` instead", "Use `Baz` instead"),
("Use :meth:`Baz.bar` instead", "Use `Baz.bar` instead"),
("Use :method:`Baz.bar` instead", "Use `Baz.bar` instead"),
# other examples using a domain :
("Use :py:func:`bar` instead", "Use `bar` instead"),
("Use :cpp:func:`bar` instead", "Use `bar` instead"),
("Use :js:func:`bar` instead", "Use `bar` instead"),
# the reference can have special characters:
("Use :func:`~pkg.mod.bar` instead", "Use `~pkg.mod.bar` instead"),
# edge cases:
("Use :r:`` instead", "Use `` instead"),
("Use :d:r:`` instead", "Use `` instead"),
("Use :r:`foo` instead", "Use `foo` instead"),
("Use :d:r:`foo` instead", "Use `foo` instead"),
("Use r:`bad` instead", "Use r:`bad` instead"),
("Use ::`bad` instead", "Use ::`bad` instead"),
("Use :::`bad` instead", "Use :::`bad` instead"),
],
)
def test_get_deprecated_msg(reason, expected):
adapter = deprecated.sphinx.SphinxAdapter("deprecated", reason=reason, version="1")
actual = adapter.get_deprecated_msg(lambda: None, None)
> assert expected in actual
E TypeError: argument of type 'NoneType' is not iterable
tests/test_sphinx.py:424: TypeError
test_sphinx.py::test_get_deprecated_msg[Use :function:bar
instead-Use bar
instead]
test_sphinx.py::test_get_deprecated_msg[Use :function:`bar` instead-Use `bar` instead]
reason = 'Use :function:`bar` instead', expected = 'Use `bar` instead'
@pytest.mark.parametrize(
"reason, expected",
[
# classic examples using the default domain (Python)
("Use :func:`bar` instead", "Use `bar` instead"),
("Use :function:`bar` instead", "Use `bar` instead"),
("Use :class:`Baz` instead", "Use `Baz` instead"),
("Use :exc:`Baz` instead", "Use `Baz` instead"),
("Use :exception:`Baz` instead", "Use `Baz` instead"),
("Use :meth:`Baz.bar` instead", "Use `Baz.bar` instead"),
("Use :method:`Baz.bar` instead", "Use `Baz.bar` instead"),
# other examples using a domain :
("Use :py:func:`bar` instead", "Use `bar` instead"),
("Use :cpp:func:`bar` instead", "Use `bar` instead"),
("Use :js:func:`bar` instead", "Use `bar` instead"),
# the reference can have special characters:
("Use :func:`~pkg.mod.bar` instead", "Use `~pkg.mod.bar` instead"),
# edge cases:
("Use :r:`` instead", "Use `` instead"),
("Use :d:r:`` instead", "Use `` instead"),
("Use :r:`foo` instead", "Use `foo` instead"),
("Use :d:r:`foo` instead", "Use `foo` instead"),
("Use r:`bad` instead", "Use r:`bad` instead"),
("Use ::`bad` instead", "Use ::`bad` instead"),
("Use :::`bad` instead", "Use :::`bad` instead"),
],
)
def test_get_deprecated_msg(reason, expected):
adapter = deprecated.sphinx.SphinxAdapter("deprecated", reason=reason, version="1")
actual = adapter.get_deprecated_msg(lambda: None, None)
> assert expected in actual
E TypeError: argument of type 'NoneType' is not iterable
tests/test_sphinx.py:424: TypeError
test_sphinx.py::test_get_deprecated_msg[Use :class:Baz
instead-Use Baz
instead]
test_sphinx.py::test_get_deprecated_msg[Use :class:`Baz` instead-Use `Baz` instead]
reason = 'Use :class:`Baz` instead', expected = 'Use `Baz` instead'
@pytest.mark.parametrize(
"reason, expected",
[
# classic examples using the default domain (Python)
("Use :func:`bar` instead", "Use `bar` instead"),
("Use :function:`bar` instead", "Use `bar` instead"),
("Use :class:`Baz` instead", "Use `Baz` instead"),
("Use :exc:`Baz` instead", "Use `Baz` instead"),
("Use :exception:`Baz` instead", "Use `Baz` instead"),
("Use :meth:`Baz.bar` instead", "Use `Baz.bar` instead"),
("Use :method:`Baz.bar` instead", "Use `Baz.bar` instead"),
# other examples using a domain :
("Use :py:func:`bar` instead", "Use `bar` instead"),
("Use :cpp:func:`bar` instead", "Use `bar` instead"),
("Use :js:func:`bar` instead", "Use `bar` instead"),
# the reference can have special characters:
("Use :func:`~pkg.mod.bar` instead", "Use `~pkg.mod.bar` instead"),
# edge cases:
("Use :r:`` instead", "Use `` instead"),
("Use :d:r:`` instead", "Use `` instead"),
("Use :r:`foo` instead", "Use `foo` instead"),
("Use :d:r:`foo` instead", "Use `foo` instead"),
("Use r:`bad` instead", "Use r:`bad` instead"),
("Use ::`bad` instead", "Use ::`bad` instead"),
("Use :::`bad` instead", "Use :::`bad` instead"),
],
)
def test_get_deprecated_msg(reason, expected):
adapter = deprecated.sphinx.SphinxAdapter("deprecated", reason=reason, version="1")
actual = adapter.get_deprecated_msg(lambda: None, None)
> assert expected in actual
E TypeError: argument of type 'NoneType' is not iterable
tests/test_sphinx.py:424: TypeError
test_sphinx.py::test_get_deprecated_msg[Use :exc:Baz
instead-Use Baz
instead]
test_sphinx.py::test_get_deprecated_msg[Use :exc:`Baz` instead-Use `Baz` instead]
reason = 'Use :exc:`Baz` instead', expected = 'Use `Baz` instead'
@pytest.mark.parametrize(
"reason, expected",
[
# classic examples using the default domain (Python)
("Use :func:`bar` instead", "Use `bar` instead"),
("Use :function:`bar` instead", "Use `bar` instead"),
("Use :class:`Baz` instead", "Use `Baz` instead"),
("Use :exc:`Baz` instead", "Use `Baz` instead"),
("Use :exception:`Baz` instead", "Use `Baz` instead"),
("Use :meth:`Baz.bar` instead", "Use `Baz.bar` instead"),
("Use :method:`Baz.bar` instead", "Use `Baz.bar` instead"),
# other examples using a domain :
("Use :py:func:`bar` instead", "Use `bar` instead"),
("Use :cpp:func:`bar` instead", "Use `bar` instead"),
("Use :js:func:`bar` instead", "Use `bar` instead"),
# the reference can have special characters:
("Use :func:`~pkg.mod.bar` instead", "Use `~pkg.mod.bar` instead"),
# edge cases:
("Use :r:`` instead", "Use `` instead"),
("Use :d:r:`` instead", "Use `` instead"),
("Use :r:`foo` instead", "Use `foo` instead"),
("Use :d:r:`foo` instead", "Use `foo` instead"),
("Use r:`bad` instead", "Use r:`bad` instead"),
("Use ::`bad` instead", "Use ::`bad` instead"),
("Use :::`bad` instead", "Use :::`bad` instead"),
],
)
def test_get_deprecated_msg(reason, expected):
adapter = deprecated.sphinx.SphinxAdapter("deprecated", reason=reason, version="1")
actual = adapter.get_deprecated_msg(lambda: None, None)
> assert expected in actual
E TypeError: argument of type 'NoneType' is not iterable
tests/test_sphinx.py:424: TypeError
test_sphinx.py::test_get_deprecated_msg[Use :exception:Baz
instead-Use Baz
instead]
test_sphinx.py::test_get_deprecated_msg[Use :exception:`Baz` instead-Use `Baz` instead]
reason = 'Use :exception:`Baz` instead', expected = 'Use `Baz` instead'
@pytest.mark.parametrize(
"reason, expected",
[
# classic examples using the default domain (Python)
("Use :func:`bar` instead", "Use `bar` instead"),
("Use :function:`bar` instead", "Use `bar` instead"),
("Use :class:`Baz` instead", "Use `Baz` instead"),
("Use :exc:`Baz` instead", "Use `Baz` instead"),
("Use :exception:`Baz` instead", "Use `Baz` instead"),
("Use :meth:`Baz.bar` instead", "Use `Baz.bar` instead"),
("Use :method:`Baz.bar` instead", "Use `Baz.bar` instead"),
# other examples using a domain :
("Use :py:func:`bar` instead", "Use `bar` instead"),
("Use :cpp:func:`bar` instead", "Use `bar` instead"),
("Use :js:func:`bar` instead", "Use `bar` instead"),
# the reference can have special characters:
("Use :func:`~pkg.mod.bar` instead", "Use `~pkg.mod.bar` instead"),
# edge cases:
("Use :r:`` instead", "Use `` instead"),
("Use :d:r:`` instead", "Use `` instead"),
("Use :r:`foo` instead", "Use `foo` instead"),
("Use :d:r:`foo` instead", "Use `foo` instead"),
("Use r:`bad` instead", "Use r:`bad` instead"),
("Use ::`bad` instead", "Use ::`bad` instead"),
("Use :::`bad` instead", "Use :::`bad` instead"),
],
)
def test_get_deprecated_msg(reason, expected):
adapter = deprecated.sphinx.SphinxAdapter("deprecated", reason=reason, version="1")
actual = adapter.get_deprecated_msg(lambda: None, None)
> assert expected in actual
E TypeError: argument of type 'NoneType' is not iterable
tests/test_sphinx.py:424: TypeError
test_sphinx.py::test_get_deprecated_msg[Use :meth:Baz.bar
instead-Use Baz.bar
instead]
test_sphinx.py::test_get_deprecated_msg[Use :meth:`Baz.bar` instead-Use `Baz.bar` instead]
reason = 'Use :meth:`Baz.bar` instead', expected = 'Use `Baz.bar` instead'
@pytest.mark.parametrize(
"reason, expected",
[
# classic examples using the default domain (Python)
("Use :func:`bar` instead", "Use `bar` instead"),
("Use :function:`bar` instead", "Use `bar` instead"),
("Use :class:`Baz` instead", "Use `Baz` instead"),
("Use :exc:`Baz` instead", "Use `Baz` instead"),
("Use :exception:`Baz` instead", "Use `Baz` instead"),
("Use :meth:`Baz.bar` instead", "Use `Baz.bar` instead"),
("Use :method:`Baz.bar` instead", "Use `Baz.bar` instead"),
# other examples using a domain :
("Use :py:func:`bar` instead", "Use `bar` instead"),
("Use :cpp:func:`bar` instead", "Use `bar` instead"),
("Use :js:func:`bar` instead", "Use `bar` instead"),
# the reference can have special characters:
("Use :func:`~pkg.mod.bar` instead", "Use `~pkg.mod.bar` instead"),
# edge cases:
("Use :r:`` instead", "Use `` instead"),
("Use :d:r:`` instead", "Use `` instead"),
("Use :r:`foo` instead", "Use `foo` instead"),
("Use :d:r:`foo` instead", "Use `foo` instead"),
("Use r:`bad` instead", "Use r:`bad` instead"),
("Use ::`bad` instead", "Use ::`bad` instead"),
("Use :::`bad` instead", "Use :::`bad` instead"),
],
)
def test_get_deprecated_msg(reason, expected):
adapter = deprecated.sphinx.SphinxAdapter("deprecated", reason=reason, version="1")
actual = adapter.get_deprecated_msg(lambda: None, None)
> assert expected in actual
E TypeError: argument of type 'NoneType' is not iterable
tests/test_sphinx.py:424: TypeError
test_sphinx.py::test_get_deprecated_msg[Use :method:Baz.bar
instead-Use Baz.bar
instead]
test_sphinx.py::test_get_deprecated_msg[Use :method:`Baz.bar` instead-Use `Baz.bar` instead]
reason = 'Use :method:`Baz.bar` instead', expected = 'Use `Baz.bar` instead'
@pytest.mark.parametrize(
"reason, expected",
[
# classic examples using the default domain (Python)
("Use :func:`bar` instead", "Use `bar` instead"),
("Use :function:`bar` instead", "Use `bar` instead"),
("Use :class:`Baz` instead", "Use `Baz` instead"),
("Use :exc:`Baz` instead", "Use `Baz` instead"),
("Use :exception:`Baz` instead", "Use `Baz` instead"),
("Use :meth:`Baz.bar` instead", "Use `Baz.bar` instead"),
("Use :method:`Baz.bar` instead", "Use `Baz.bar` instead"),
# other examples using a domain :
("Use :py:func:`bar` instead", "Use `bar` instead"),
("Use :cpp:func:`bar` instead", "Use `bar` instead"),
("Use :js:func:`bar` instead", "Use `bar` instead"),
# the reference can have special characters:
("Use :func:`~pkg.mod.bar` instead", "Use `~pkg.mod.bar` instead"),
# edge cases:
("Use :r:`` instead", "Use `` instead"),
("Use :d:r:`` instead", "Use `` instead"),
("Use :r:`foo` instead", "Use `foo` instead"),
("Use :d:r:`foo` instead", "Use `foo` instead"),
("Use r:`bad` instead", "Use r:`bad` instead"),
("Use ::`bad` instead", "Use ::`bad` instead"),
("Use :::`bad` instead", "Use :::`bad` instead"),
],
)
def test_get_deprecated_msg(reason, expected):
adapter = deprecated.sphinx.SphinxAdapter("deprecated", reason=reason, version="1")
actual = adapter.get_deprecated_msg(lambda: None, None)
> assert expected in actual
E TypeError: argument of type 'NoneType' is not iterable
tests/test_sphinx.py:424: TypeError
test_sphinx.py::test_get_deprecated_msg[Use :py:func:bar
instead-Use bar
instead]
test_sphinx.py::test_get_deprecated_msg[Use :py:func:`bar` instead-Use `bar` instead]
reason = 'Use :py:func:`bar` instead', expected = 'Use `bar` instead'
@pytest.mark.parametrize(
"reason, expected",
[
# classic examples using the default domain (Python)
("Use :func:`bar` instead", "Use `bar` instead"),
("Use :function:`bar` instead", "Use `bar` instead"),
("Use :class:`Baz` instead", "Use `Baz` instead"),
("Use :exc:`Baz` instead", "Use `Baz` instead"),
("Use :exception:`Baz` instead", "Use `Baz` instead"),
("Use :meth:`Baz.bar` instead", "Use `Baz.bar` instead"),
("Use :method:`Baz.bar` instead", "Use `Baz.bar` instead"),
# other examples using a domain :
("Use :py:func:`bar` instead", "Use `bar` instead"),
("Use :cpp:func:`bar` instead", "Use `bar` instead"),
("Use :js:func:`bar` instead", "Use `bar` instead"),
# the reference can have special characters:
("Use :func:`~pkg.mod.bar` instead", "Use `~pkg.mod.bar` instead"),
# edge cases:
("Use :r:`` instead", "Use `` instead"),
("Use :d:r:`` instead", "Use `` instead"),
("Use :r:`foo` instead", "Use `foo` instead"),
("Use :d:r:`foo` instead", "Use `foo` instead"),
("Use r:`bad` instead", "Use r:`bad` instead"),
("Use ::`bad` instead", "Use ::`bad` instead"),
("Use :::`bad` instead", "Use :::`bad` instead"),
],
)
def test_get_deprecated_msg(reason, expected):
adapter = deprecated.sphinx.SphinxAdapter("deprecated", reason=reason, version="1")
actual = adapter.get_deprecated_msg(lambda: None, None)
> assert expected in actual
E TypeError: argument of type 'NoneType' is not iterable
tests/test_sphinx.py:424: TypeError
test_sphinx.py::test_get_deprecated_msg[Use :cpp:func:bar
instead-Use bar
instead]
test_sphinx.py::test_get_deprecated_msg[Use :cpp:func:`bar` instead-Use `bar` instead]
reason = 'Use :cpp:func:`bar` instead', expected = 'Use `bar` instead'
@pytest.mark.parametrize(
"reason, expected",
[
# classic examples using the default domain (Python)
("Use :func:`bar` instead", "Use `bar` instead"),
("Use :function:`bar` instead", "Use `bar` instead"),
("Use :class:`Baz` instead", "Use `Baz` instead"),
("Use :exc:`Baz` instead", "Use `Baz` instead"),
("Use :exception:`Baz` instead", "Use `Baz` instead"),
("Use :meth:`Baz.bar` instead", "Use `Baz.bar` instead"),
("Use :method:`Baz.bar` instead", "Use `Baz.bar` instead"),
# other examples using a domain :
("Use :py:func:`bar` instead", "Use `bar` instead"),
("Use :cpp:func:`bar` instead", "Use `bar` instead"),
("Use :js:func:`bar` instead", "Use `bar` instead"),
# the reference can have special characters:
("Use :func:`~pkg.mod.bar` instead", "Use `~pkg.mod.bar` instead"),
# edge cases:
("Use :r:`` instead", "Use `` instead"),
("Use :d:r:`` instead", "Use `` instead"),
("Use :r:`foo` instead", "Use `foo` instead"),
("Use :d:r:`foo` instead", "Use `foo` instead"),
("Use r:`bad` instead", "Use r:`bad` instead"),
("Use ::`bad` instead", "Use ::`bad` instead"),
("Use :::`bad` instead", "Use :::`bad` instead"),
],
)
def test_get_deprecated_msg(reason, expected):
adapter = deprecated.sphinx.SphinxAdapter("deprecated", reason=reason, version="1")
actual = adapter.get_deprecated_msg(lambda: None, None)
> assert expected in actual
E TypeError: argument of type 'NoneType' is not iterable
tests/test_sphinx.py:424: TypeError
test_sphinx.py::test_get_deprecated_msg[Use :js:func:bar
instead-Use bar
instead]
test_sphinx.py::test_get_deprecated_msg[Use :js:func:`bar` instead-Use `bar` instead]
reason = 'Use :js:func:`bar` instead', expected = 'Use `bar` instead'
@pytest.mark.parametrize(
"reason, expected",
[
# classic examples using the default domain (Python)
("Use :func:`bar` instead", "Use `bar` instead"),
("Use :function:`bar` instead", "Use `bar` instead"),
("Use :class:`Baz` instead", "Use `Baz` instead"),
("Use :exc:`Baz` instead", "Use `Baz` instead"),
("Use :exception:`Baz` instead", "Use `Baz` instead"),
("Use :meth:`Baz.bar` instead", "Use `Baz.bar` instead"),
("Use :method:`Baz.bar` instead", "Use `Baz.bar` instead"),
# other examples using a domain :
("Use :py:func:`bar` instead", "Use `bar` instead"),
("Use :cpp:func:`bar` instead", "Use `bar` instead"),
("Use :js:func:`bar` instead", "Use `bar` instead"),
# the reference can have special characters:
("Use :func:`~pkg.mod.bar` instead", "Use `~pkg.mod.bar` instead"),
# edge cases:
("Use :r:`` instead", "Use `` instead"),
("Use :d:r:`` instead", "Use `` instead"),
("Use :r:`foo` instead", "Use `foo` instead"),
("Use :d:r:`foo` instead", "Use `foo` instead"),
("Use r:`bad` instead", "Use r:`bad` instead"),
("Use ::`bad` instead", "Use ::`bad` instead"),
("Use :::`bad` instead", "Use :::`bad` instead"),
],
)
def test_get_deprecated_msg(reason, expected):
adapter = deprecated.sphinx.SphinxAdapter("deprecated", reason=reason, version="1")
actual = adapter.get_deprecated_msg(lambda: None, None)
> assert expected in actual
E TypeError: argument of type 'NoneType' is not iterable
tests/test_sphinx.py:424: TypeError
test_sphinx.py::test_get_deprecated_msg[Use :func:~pkg.mod.bar
instead-Use ~pkg.mod.bar
instead]
test_sphinx.py::test_get_deprecated_msg[Use :func:`~pkg.mod.bar` instead-Use `~pkg.mod.bar` instead]
reason = 'Use :func:`~pkg.mod.bar` instead'
expected = 'Use `~pkg.mod.bar` instead'
@pytest.mark.parametrize(
"reason, expected",
[
# classic examples using the default domain (Python)
("Use :func:`bar` instead", "Use `bar` instead"),
("Use :function:`bar` instead", "Use `bar` instead"),
("Use :class:`Baz` instead", "Use `Baz` instead"),
("Use :exc:`Baz` instead", "Use `Baz` instead"),
("Use :exception:`Baz` instead", "Use `Baz` instead"),
("Use :meth:`Baz.bar` instead", "Use `Baz.bar` instead"),
("Use :method:`Baz.bar` instead", "Use `Baz.bar` instead"),
# other examples using a domain :
("Use :py:func:`bar` instead", "Use `bar` instead"),
("Use :cpp:func:`bar` instead", "Use `bar` instead"),
("Use :js:func:`bar` instead", "Use `bar` instead"),
# the reference can have special characters:
("Use :func:`~pkg.mod.bar` instead", "Use `~pkg.mod.bar` instead"),
# edge cases:
("Use :r:`` instead", "Use `` instead"),
("Use :d:r:`` instead", "Use `` instead"),
("Use :r:`foo` instead", "Use `foo` instead"),
("Use :d:r:`foo` instead", "Use `foo` instead"),
("Use r:`bad` instead", "Use r:`bad` instead"),
("Use ::`bad` instead", "Use ::`bad` instead"),
("Use :::`bad` instead", "Use :::`bad` instead"),
],
)
def test_get_deprecated_msg(reason, expected):
adapter = deprecated.sphinx.SphinxAdapter("deprecated", reason=reason, version="1")
actual = adapter.get_deprecated_msg(lambda: None, None)
> assert expected in actual
E TypeError: argument of type 'NoneType' is not iterable
tests/test_sphinx.py:424: TypeError
test_sphinx.py::test_get_deprecated_msg[Use :r:instead-Use
instead]
test_sphinx.py::test_get_deprecated_msg[Use :r:`` instead-Use `` instead]
reason = 'Use :r:`` instead', expected = 'Use `` instead'
@pytest.mark.parametrize(
"reason, expected",
[
# classic examples using the default domain (Python)
("Use :func:`bar` instead", "Use `bar` instead"),
("Use :function:`bar` instead", "Use `bar` instead"),
("Use :class:`Baz` instead", "Use `Baz` instead"),
("Use :exc:`Baz` instead", "Use `Baz` instead"),
("Use :exception:`Baz` instead", "Use `Baz` instead"),
("Use :meth:`Baz.bar` instead", "Use `Baz.bar` instead"),
("Use :method:`Baz.bar` instead", "Use `Baz.bar` instead"),
# other examples using a domain :
("Use :py:func:`bar` instead", "Use `bar` instead"),
("Use :cpp:func:`bar` instead", "Use `bar` instead"),
("Use :js:func:`bar` instead", "Use `bar` instead"),
# the reference can have special characters:
("Use :func:`~pkg.mod.bar` instead", "Use `~pkg.mod.bar` instead"),
# edge cases:
("Use :r:`` instead", "Use `` instead"),
("Use :d:r:`` instead", "Use `` instead"),
("Use :r:`foo` instead", "Use `foo` instead"),
("Use :d:r:`foo` instead", "Use `foo` instead"),
("Use r:`bad` instead", "Use r:`bad` instead"),
("Use ::`bad` instead", "Use ::`bad` instead"),
("Use :::`bad` instead", "Use :::`bad` instead"),
],
)
def test_get_deprecated_msg(reason, expected):
adapter = deprecated.sphinx.SphinxAdapter("deprecated", reason=reason, version="1")
actual = adapter.get_deprecated_msg(lambda: None, None)
> assert expected in actual
E TypeError: argument of type 'NoneType' is not iterable
tests/test_sphinx.py:424: TypeError
test_sphinx.py::test_get_deprecated_msg[Use :d:r:instead-Use
instead]
test_sphinx.py::test_get_deprecated_msg[Use :d:r:`` instead-Use `` instead]
reason = 'Use :d:r:`` instead', expected = 'Use `` instead'
@pytest.mark.parametrize(
"reason, expected",
[
# classic examples using the default domain (Python)
("Use :func:`bar` instead", "Use `bar` instead"),
("Use :function:`bar` instead", "Use `bar` instead"),
("Use :class:`Baz` instead", "Use `Baz` instead"),
("Use :exc:`Baz` instead", "Use `Baz` instead"),
("Use :exception:`Baz` instead", "Use `Baz` instead"),
("Use :meth:`Baz.bar` instead", "Use `Baz.bar` instead"),
("Use :method:`Baz.bar` instead", "Use `Baz.bar` instead"),
# other examples using a domain :
("Use :py:func:`bar` instead", "Use `bar` instead"),
("Use :cpp:func:`bar` instead", "Use `bar` instead"),
("Use :js:func:`bar` instead", "Use `bar` instead"),
# the reference can have special characters:
("Use :func:`~pkg.mod.bar` instead", "Use `~pkg.mod.bar` instead"),
# edge cases:
("Use :r:`` instead", "Use `` instead"),
("Use :d:r:`` instead", "Use `` instead"),
("Use :r:`foo` instead", "Use `foo` instead"),
("Use :d:r:`foo` instead", "Use `foo` instead"),
("Use r:`bad` instead", "Use r:`bad` instead"),
("Use ::`bad` instead", "Use ::`bad` instead"),
("Use :::`bad` instead", "Use :::`bad` instead"),
],
)
def test_get_deprecated_msg(reason, expected):
adapter = deprecated.sphinx.SphinxAdapter("deprecated", reason=reason, version="1")
actual = adapter.get_deprecated_msg(lambda: None, None)
> assert expected in actual
E TypeError: argument of type 'NoneType' is not iterable
tests/test_sphinx.py:424: TypeError
test_sphinx.py::test_get_deprecated_msg[Use :r:foo
instead-Use foo
instead]
test_sphinx.py::test_get_deprecated_msg[Use :r:`foo` instead-Use `foo` instead]
reason = 'Use :r:`foo` instead', expected = 'Use `foo` instead'
@pytest.mark.parametrize(
"reason, expected",
[
# classic examples using the default domain (Python)
("Use :func:`bar` instead", "Use `bar` instead"),
("Use :function:`bar` instead", "Use `bar` instead"),
("Use :class:`Baz` instead", "Use `Baz` instead"),
("Use :exc:`Baz` instead", "Use `Baz` instead"),
("Use :exception:`Baz` instead", "Use `Baz` instead"),
("Use :meth:`Baz.bar` instead", "Use `Baz.bar` instead"),
("Use :method:`Baz.bar` instead", "Use `Baz.bar` instead"),
# other examples using a domain :
("Use :py:func:`bar` instead", "Use `bar` instead"),
("Use :cpp:func:`bar` instead", "Use `bar` instead"),
("Use :js:func:`bar` instead", "Use `bar` instead"),
# the reference can have special characters:
("Use :func:`~pkg.mod.bar` instead", "Use `~pkg.mod.bar` instead"),
# edge cases:
("Use :r:`` instead", "Use `` instead"),
("Use :d:r:`` instead", "Use `` instead"),
("Use :r:`foo` instead", "Use `foo` instead"),
("Use :d:r:`foo` instead", "Use `foo` instead"),
("Use r:`bad` instead", "Use r:`bad` instead"),
("Use ::`bad` instead", "Use ::`bad` instead"),
("Use :::`bad` instead", "Use :::`bad` instead"),
],
)
def test_get_deprecated_msg(reason, expected):
adapter = deprecated.sphinx.SphinxAdapter("deprecated", reason=reason, version="1")
actual = adapter.get_deprecated_msg(lambda: None, None)
> assert expected in actual
E TypeError: argument of type 'NoneType' is not iterable
tests/test_sphinx.py:424: TypeError
test_sphinx.py::test_get_deprecated_msg[Use :d:r:foo
instead-Use foo
instead]
test_sphinx.py::test_get_deprecated_msg[Use :d:r:`foo` instead-Use `foo` instead]
reason = 'Use :d:r:`foo` instead', expected = 'Use `foo` instead'
@pytest.mark.parametrize(
"reason, expected",
[
# classic examples using the default domain (Python)
("Use :func:`bar` instead", "Use `bar` instead"),
("Use :function:`bar` instead", "Use `bar` instead"),
("Use :class:`Baz` instead", "Use `Baz` instead"),
("Use :exc:`Baz` instead", "Use `Baz` instead"),
("Use :exception:`Baz` instead", "Use `Baz` instead"),
("Use :meth:`Baz.bar` instead", "Use `Baz.bar` instead"),
("Use :method:`Baz.bar` instead", "Use `Baz.bar` instead"),
# other examples using a domain :
("Use :py:func:`bar` instead", "Use `bar` instead"),
("Use :cpp:func:`bar` instead", "Use `bar` instead"),
("Use :js:func:`bar` instead", "Use `bar` instead"),
# the reference can have special characters:
("Use :func:`~pkg.mod.bar` instead", "Use `~pkg.mod.bar` instead"),
# edge cases:
("Use :r:`` instead", "Use `` instead"),
("Use :d:r:`` instead", "Use `` instead"),
("Use :r:`foo` instead", "Use `foo` instead"),
("Use :d:r:`foo` instead", "Use `foo` instead"),
("Use r:`bad` instead", "Use r:`bad` instead"),
("Use ::`bad` instead", "Use ::`bad` instead"),
("Use :::`bad` instead", "Use :::`bad` instead"),
],
)
def test_get_deprecated_msg(reason, expected):
adapter = deprecated.sphinx.SphinxAdapter("deprecated", reason=reason, version="1")
actual = adapter.get_deprecated_msg(lambda: None, None)
> assert expected in actual
E TypeError: argument of type 'NoneType' is not iterable
tests/test_sphinx.py:424: TypeError
test_sphinx.py::test_get_deprecated_msg[Use r:bad
instead-Use r:bad
instead]
test_sphinx.py::test_get_deprecated_msg[Use r:`bad` instead-Use r:`bad` instead]
reason = 'Use r:`bad` instead', expected = 'Use r:`bad` instead'
@pytest.mark.parametrize(
"reason, expected",
[
# classic examples using the default domain (Python)
("Use :func:`bar` instead", "Use `bar` instead"),
("Use :function:`bar` instead", "Use `bar` instead"),
("Use :class:`Baz` instead", "Use `Baz` instead"),
("Use :exc:`Baz` instead", "Use `Baz` instead"),
("Use :exception:`Baz` instead", "Use `Baz` instead"),
("Use :meth:`Baz.bar` instead", "Use `Baz.bar` instead"),
("Use :method:`Baz.bar` instead", "Use `Baz.bar` instead"),
# other examples using a domain :
("Use :py:func:`bar` instead", "Use `bar` instead"),
("Use :cpp:func:`bar` instead", "Use `bar` instead"),
("Use :js:func:`bar` instead", "Use `bar` instead"),
# the reference can have special characters:
("Use :func:`~pkg.mod.bar` instead", "Use `~pkg.mod.bar` instead"),
# edge cases:
("Use :r:`` instead", "Use `` instead"),
("Use :d:r:`` instead", "Use `` instead"),
("Use :r:`foo` instead", "Use `foo` instead"),
("Use :d:r:`foo` instead", "Use `foo` instead"),
("Use r:`bad` instead", "Use r:`bad` instead"),
("Use ::`bad` instead", "Use ::`bad` instead"),
("Use :::`bad` instead", "Use :::`bad` instead"),
],
)
def test_get_deprecated_msg(reason, expected):
adapter = deprecated.sphinx.SphinxAdapter("deprecated", reason=reason, version="1")
actual = adapter.get_deprecated_msg(lambda: None, None)
> assert expected in actual
E TypeError: argument of type 'NoneType' is not iterable
tests/test_sphinx.py:424: TypeError
test_sphinx.py::test_get_deprecated_msg[Use ::bad
instead-Use ::bad
instead]
test_sphinx.py::test_get_deprecated_msg[Use ::`bad` instead-Use ::`bad` instead]
reason = 'Use ::`bad` instead', expected = 'Use ::`bad` instead'
@pytest.mark.parametrize(
"reason, expected",
[
# classic examples using the default domain (Python)
("Use :func:`bar` instead", "Use `bar` instead"),
("Use :function:`bar` instead", "Use `bar` instead"),
("Use :class:`Baz` instead", "Use `Baz` instead"),
("Use :exc:`Baz` instead", "Use `Baz` instead"),
("Use :exception:`Baz` instead", "Use `Baz` instead"),
("Use :meth:`Baz.bar` instead", "Use `Baz.bar` instead"),
("Use :method:`Baz.bar` instead", "Use `Baz.bar` instead"),
# other examples using a domain :
("Use :py:func:`bar` instead", "Use `bar` instead"),
("Use :cpp:func:`bar` instead", "Use `bar` instead"),
("Use :js:func:`bar` instead", "Use `bar` instead"),
# the reference can have special characters:
("Use :func:`~pkg.mod.bar` instead", "Use `~pkg.mod.bar` instead"),
# edge cases:
("Use :r:`` instead", "Use `` instead"),
("Use :d:r:`` instead", "Use `` instead"),
("Use :r:`foo` instead", "Use `foo` instead"),
("Use :d:r:`foo` instead", "Use `foo` instead"),
("Use r:`bad` instead", "Use r:`bad` instead"),
("Use ::`bad` instead", "Use ::`bad` instead"),
("Use :::`bad` instead", "Use :::`bad` instead"),
],
)
def test_get_deprecated_msg(reason, expected):
adapter = deprecated.sphinx.SphinxAdapter("deprecated", reason=reason, version="1")
actual = adapter.get_deprecated_msg(lambda: None, None)
> assert expected in actual
E TypeError: argument of type 'NoneType' is not iterable
tests/test_sphinx.py:424: TypeError
test_sphinx.py::test_get_deprecated_msg[Use :::bad
instead-Use :::bad
instead]
test_sphinx.py::test_get_deprecated_msg[Use :::`bad` instead-Use :::`bad` instead]
reason = 'Use :::`bad` instead', expected = 'Use :::`bad` instead'
@pytest.mark.parametrize(
"reason, expected",
[
# classic examples using the default domain (Python)
("Use :func:`bar` instead", "Use `bar` instead"),
("Use :function:`bar` instead", "Use `bar` instead"),
("Use :class:`Baz` instead", "Use `Baz` instead"),
("Use :exc:`Baz` instead", "Use `Baz` instead"),
("Use :exception:`Baz` instead", "Use `Baz` instead"),
("Use :meth:`Baz.bar` instead", "Use `Baz.bar` instead"),
("Use :method:`Baz.bar` instead", "Use `Baz.bar` instead"),
# other examples using a domain :
("Use :py:func:`bar` instead", "Use `bar` instead"),
("Use :cpp:func:`bar` instead", "Use `bar` instead"),
("Use :js:func:`bar` instead", "Use `bar` instead"),
# the reference can have special characters:
("Use :func:`~pkg.mod.bar` instead", "Use `~pkg.mod.bar` instead"),
# edge cases:
("Use :r:`` instead", "Use `` instead"),
("Use :d:r:`` instead", "Use `` instead"),
("Use :r:`foo` instead", "Use `foo` instead"),
("Use :d:r:`foo` instead", "Use `foo` instead"),
("Use r:`bad` instead", "Use r:`bad` instead"),
("Use ::`bad` instead", "Use ::`bad` instead"),
("Use :::`bad` instead", "Use :::`bad` instead"),
],
)
def test_get_deprecated_msg(reason, expected):
adapter = deprecated.sphinx.SphinxAdapter("deprecated", reason=reason, version="1")
actual = adapter.get_deprecated_msg(lambda: None, None)
> assert expected in actual
E TypeError: argument of type 'NoneType' is not iterable
tests/test_sphinx.py:424: TypeError
test_sphinx_adapter.py::test_decorator_accept_line_length[versionadded-versionadded]
test_sphinx_adapter.py::test_decorator_accept_line_length[versionadded-versionadded]
decorator_factory =
directive = 'versionadded'
@pytest.mark.parametrize(
"decorator_factory, directive",
[
(versionadded, "versionadded"),
(versionchanged, "versionchanged"),
(deprecated, "deprecated"),
],
)
def test_decorator_accept_line_length(decorator_factory, directive):
reason = "bar " * 30
decorator = decorator_factory(reason=reason, version="1.2.3", line_length=50)
def foo():
pass
> foo = decorator(foo)
E TypeError: 'NoneType' object is not callable
tests/test_sphinx_adapter.py:117: TypeError
test_sphinx_adapter.py::test_decorator_accept_line_length[versionchanged-versionchanged]
test_sphinx_adapter.py::test_decorator_accept_line_length[versionchanged-versionchanged]
decorator_factory =
directive = 'versionchanged'
@pytest.mark.parametrize(
"decorator_factory, directive",
[
(versionadded, "versionadded"),
(versionchanged, "versionchanged"),
(deprecated, "deprecated"),
],
)
def test_decorator_accept_line_length(decorator_factory, directive):
reason = "bar " * 30
decorator = decorator_factory(reason=reason, version="1.2.3", line_length=50)
def foo():
pass
> foo = decorator(foo)
E TypeError: 'NoneType' object is not callable
tests/test_sphinx_adapter.py:117: TypeError
test_sphinx_adapter.py::test_decorator_accept_line_length[deprecated-deprecated]
test_sphinx_adapter.py::test_decorator_accept_line_length[deprecated-deprecated]
decorator_factory =
directive = 'deprecated'
@pytest.mark.parametrize(
"decorator_factory, directive",
[
(versionadded, "versionadded"),
(versionchanged, "versionchanged"),
(deprecated, "deprecated"),
],
)
def test_decorator_accept_line_length(decorator_factory, directive):
reason = "bar " * 30
decorator = decorator_factory(reason=reason, version="1.2.3", line_length=50)
def foo():
pass
> foo = decorator(foo)
E TypeError: 'NoneType' object is not callable
tests/test_sphinx_adapter.py:117: TypeError
test_sphinx_class.py::test_class_deprecation_using_deprecated_decorator
test_sphinx_class.py::test_class_deprecation_using_deprecated_decorator
@pytest.mark.skipif(
sys.version_info < (3, 3), reason="Classes should have mutable docstrings -- resolved in python 3.3"
)
def test_class_deprecation_using_deprecated_decorator():
@deprecated.sphinx.deprecated(version="7.8.9")
> class MyBaseClass(object):
E TypeError: 'NoneType' object is not callable
tests/test_sphinx_class.py:49: TypeError
test_sphinx_class.py::test_subclass_deprecation_using_deprecated_decorator
test_sphinx_class.py::test_subclass_deprecation_using_deprecated_decorator
@pytest.mark.skipif(
sys.version_info < (3, 3), reason="Classes should have mutable docstrings -- resolved in python 3.3"
)
def test_subclass_deprecation_using_deprecated_decorator():
@deprecated.sphinx.deprecated(version="7.8.9")
> class MyBaseClass(object):
E TypeError: 'NoneType' object is not callable
tests/test_sphinx_class.py:70: TypeError
test_sphinx_class.py::test_isinstance_versionadded
test_sphinx_class.py::test_isinstance_versionadded
@pytest.mark.skipif(
sys.version_info < (3, 3), reason="Classes should have mutable docstrings -- resolved in python 3.3"
)
def test_isinstance_versionadded():
# https://github.com/tantale/deprecated/issues/48
@deprecated.sphinx.versionadded(version="X.Y", reason="some reason")
> class VersionAddedCls:
E TypeError: 'NoneType' object is not callable
tests/test_sphinx_class.py:93: TypeError
test_sphinx_class.py::test_isinstance_versionchanged
test_sphinx_class.py::test_isinstance_versionchanged
@pytest.mark.skipif(
sys.version_info < (3, 3), reason="Classes should have mutable docstrings -- resolved in python 3.3"
)
def test_isinstance_versionchanged():
@deprecated.sphinx.versionchanged(version="X.Y", reason="some reason")
> class VersionChangedCls:
E TypeError: 'NoneType' object is not callable
tests/test_sphinx_class.py:110: TypeError
test_sphinx_class.py::test_isinstance_deprecated
test_sphinx_class.py::test_isinstance_deprecated
@pytest.mark.skipif(
sys.version_info < (3, 3), reason="Classes should have mutable docstrings -- resolved in python 3.3"
)
def test_isinstance_deprecated():
@deprecated.sphinx.deprecated(version="X.Y", reason="some reason")
> class DeprecatedCls:
E TypeError: 'NoneType' object is not callable
tests/test_sphinx_class.py:127: TypeError
test_sphinx_class.py::test_isinstance_versionadded_versionchanged
test_sphinx_class.py::test_isinstance_versionadded_versionchanged
@pytest.mark.skipif(
sys.version_info < (3, 3), reason="Classes should have mutable docstrings -- resolved in python 3.3"
)
def test_isinstance_versionadded_versionchanged():
@deprecated.sphinx.versionadded(version="X.Y")
@deprecated.sphinx.versionchanged(version="X.Y.Z")
> class AddedChangedCls:
E TypeError: 'NoneType' object is not callable
tests/test_sphinx_class.py:145: TypeError
Patch diff
diff --git a/deprecated/classic.py b/deprecated/classic.py
index 5175055..ef33d03 100644
--- a/deprecated/classic.py
+++ b/deprecated/classic.py
@@ -1,16 +1,10 @@
-"""
-Classic deprecation warning
-===========================
-
-Classic ``@deprecated`` decorator to deprecate old python classes, functions or methods.
-
-.. _The Warnings Filter: https://docs.python.org/3/library/warnings.html#the-warnings-filter
-"""
-import functools
import inspect
-import platform
import warnings
+import types
+import functools
+import platform
import wrapt
+
try:
import wrapt._wrappers
_routine_stacklevel = 2
@@ -21,86 +15,11 @@ except ImportError:
_class_stacklevel = 2
else:
_class_stacklevel = 3
+
string_types = (type(b''), type(u''))
class ClassicAdapter(wrapt.AdapterFactory):
- """
- Classic adapter -- *for advanced usage only*
-
- This adapter is used to get the deprecation message according to the wrapped object type:
- class, function, standard method, static method, or class method.
-
- This is the base class of the :class:`~deprecated.sphinx.SphinxAdapter` class
- which is used to update the wrapped object docstring.
-
- You can also inherit this class to change the deprecation message.
-
- In the following example, we change the message into "The ... is deprecated.":
-
- .. code-block:: python
-
- import inspect
-
- from deprecated.classic import ClassicAdapter
- from deprecated.classic import deprecated
-
-
- class MyClassicAdapter(ClassicAdapter):
- def get_deprecated_msg(self, wrapped, instance):
- if instance is None:
- if inspect.isclass(wrapped):
- fmt = "The class {name} is deprecated."
- else:
- fmt = "The function {name} is deprecated."
- else:
- if inspect.isclass(instance):
- fmt = "The class method {name} is deprecated."
- else:
- fmt = "The method {name} is deprecated."
- if self.reason:
- fmt += " ({reason})"
- if self.version:
- fmt += " -- Deprecated since version {version}."
- return fmt.format(name=wrapped.__name__,
- reason=self.reason or "",
- version=self.version or "")
-
- Then, you can use your ``MyClassicAdapter`` class like this in your source code:
-
- .. code-block:: python
-
- @deprecated(reason="use another function", adapter_cls=MyClassicAdapter)
- def some_old_function(x, y):
- return x + y
- """
-
def __init__(self, reason='', version='', action=None, category=DeprecationWarning):
- """
- Construct a wrapper adapter.
-
- :type reason: str
- :param reason:
- Reason message which documents the deprecation in your library (can be omitted).
-
- :type version: str
- :param version:
- Version of your project which deprecates this feature.
- If you follow the `Semantic Versioning <https://semver.org/>`_,
- the version number has the format "MAJOR.MINOR.PATCH".
-
- :type action: str
- :param action:
- A warning filter used to activate or not the deprecation warning.
- Can be one of "error", "ignore", "always", "default", "module", or "once".
- If ``None`` or empty, the the global filtering mechanism is used.
- See: `The Warnings Filter`_ in the Python documentation.
-
- :type category: type
- :param category:
- The warning category to use for the deprecation warning.
- By default, the category class is :class:`~DeprecationWarning`,
- you can inherit this class to define your own deprecation warning category.
- """
self.reason = reason or ''
self.version = version or ''
self.action = action
@@ -108,31 +27,23 @@ class ClassicAdapter(wrapt.AdapterFactory):
super(ClassicAdapter, self).__init__()
def get_deprecated_msg(self, wrapped, instance):
- """
- Get the deprecation warning message for the user.
-
- :param wrapped: Wrapped class or function.
-
- :param instance: The object to which the wrapped function was bound when it was called.
-
- :return: The warning message.
- """
- pass
+ if instance is None:
+ if inspect.isclass(wrapped):
+ fmt = "Class {name} is deprecated."
+ else:
+ fmt = "Function {name} is deprecated."
+ else:
+ if inspect.isclass(instance):
+ fmt = "Class method {name} is deprecated."
+ else:
+ fmt = "Method {name} is deprecated."
+ if self.reason:
+ fmt += " {reason}"
+ if self.version:
+ fmt += " -- Deprecated since version {version}."
+ return fmt.format(name=wrapped.__name__, reason=self.reason, version=self.version)
def __call__(self, wrapped):
- """
- Decorate your class or function.
-
- :param wrapped: Wrapped class or function.
-
- :return: the decorated class or function.
-
- .. versionchanged:: 1.2.4
- Don't pass arguments to :meth:`object.__new__` (other than *cls*).
-
- .. versionchanged:: 1.2.8
- The warning filter is not set if the *action* parameter is ``None`` or empty.
- """
if inspect.isclass(wrapped):
old_new1 = wrapped.__new__
@@ -226,4 +137,9 @@ def deprecated(*args, **kwargs):
return x + y
"""
- pass
\ No newline at end of file
+ if args and isinstance(args[0], (type, types.FunctionType, types.MethodType)):
+ # This is the decorator without arguments
+ return ClassicAdapter()(args[0])
+ else:
+ # This is the decorator with arguments
+ return ClassicAdapter(*args, **kwargs)
diff --git a/tests/test_deprecated.py b/tests/test_deprecated.py
index e4c00ef..7f3a331 100644
--- a/tests/test_deprecated.py
+++ b/tests/test_deprecated.py
@@ -1,260 +1,105 @@
-# -*- coding: utf-8 -*-
import sys
import warnings
+import unittest
-import pytest
-
-import deprecated.classic
+from deprecated.classic import deprecated
class MyDeprecationWarning(DeprecationWarning):
pass
-_PARAMS = [
- None,
- ((), {}),
- (('Good reason',), {}),
- ((), {'reason': 'Good reason'}),
- ((), {'version': '1.2.3'}),
- ((), {'action': 'once'}),
- ((), {'category': MyDeprecationWarning}),
-]
-
-
-@pytest.fixture(scope="module", params=_PARAMS)
-def classic_deprecated_function(request):
- if request.param is None:
-
- @deprecated.classic.deprecated
- def foo1():
+class TestClassicDeprecated(unittest.TestCase):
+ def _get_deprecated_func(self, *args, **kwargs):
+ @deprecated(*args, **kwargs)
+ def foo():
pass
+ return foo
- return foo1
- else:
- args, kwargs = request.param
-
- @deprecated.classic.deprecated(*args, **kwargs)
- def foo1():
+ def _get_deprecated_class(self, *args, **kwargs):
+ @deprecated(*args, **kwargs)
+ class Foo:
pass
+ return Foo
- return foo1
-
-
-@pytest.fixture(scope="module", params=_PARAMS)
-def classic_deprecated_class(request):
- if request.param is None:
-
- @deprecated.classic.deprecated
- class Foo2(object):
- pass
-
- return Foo2
- else:
- args, kwargs = request.param
-
- @deprecated.classic.deprecated(*args, **kwargs)
- class Foo2(object):
- pass
-
- return Foo2
-
-
-@pytest.fixture(scope="module", params=_PARAMS)
-def classic_deprecated_method(request):
- if request.param is None:
-
- class Foo3(object):
- @deprecated.classic.deprecated
- def foo3(self):
+ def _get_deprecated_method(self, *args, **kwargs):
+ class Foo:
+ @deprecated(*args, **kwargs)
+ def foo(self):
pass
+ return Foo
- return Foo3
- else:
- args, kwargs = request.param
-
- class Foo3(object):
- @deprecated.classic.deprecated(*args, **kwargs)
- def foo3(self):
- pass
-
- return Foo3
-
-
-@pytest.fixture(scope="module", params=_PARAMS)
-def classic_deprecated_static_method(request):
- if request.param is None:
-
- class Foo4(object):
- @staticmethod
- @deprecated.classic.deprecated
- def foo4():
- pass
-
- return Foo4.foo4
- else:
- args, kwargs = request.param
-
- class Foo4(object):
+ def _get_deprecated_static_method(self, *args, **kwargs):
+ class Foo:
@staticmethod
- @deprecated.classic.deprecated(*args, **kwargs)
- def foo4():
- pass
-
- return Foo4.foo4
-
-
-@pytest.fixture(scope="module", params=_PARAMS)
-def classic_deprecated_class_method(request):
- if request.param is None:
-
- class Foo5(object):
- @classmethod
- @deprecated.classic.deprecated
- def foo5(cls):
+ @deprecated(*args, **kwargs)
+ def foo():
pass
-
- return Foo5
- else:
- args, kwargs = request.param
-
- class Foo5(object):
- @classmethod
- @deprecated.classic.deprecated(*args, **kwargs)
- def foo5(cls):
- pass
-
- return Foo5
-
-
-# noinspection PyShadowingNames
-def test_classic_deprecated_function__warns(classic_deprecated_function):
- with warnings.catch_warnings(record=True) as warns:
- warnings.simplefilter("always")
- classic_deprecated_function()
- assert len(warns) == 1
- warn = warns[0]
- assert issubclass(warn.category, DeprecationWarning)
- assert "deprecated function (or staticmethod)" in str(warn.message)
- assert warn.filename == __file__, 'Incorrect warning stackLevel'
-
-
-# noinspection PyShadowingNames
-def test_classic_deprecated_class__warns(classic_deprecated_class):
- with warnings.catch_warnings(record=True) as warns:
- warnings.simplefilter("always")
- classic_deprecated_class()
- assert len(warns) == 1
- warn = warns[0]
- assert issubclass(warn.category, DeprecationWarning)
- assert "deprecated class" in str(warn.message)
- assert warn.filename == __file__, 'Incorrect warning stackLevel'
-
-
-# noinspection PyShadowingNames
-def test_classic_deprecated_method__warns(classic_deprecated_method):
- with warnings.catch_warnings(record=True) as warns:
- warnings.simplefilter("always")
- obj = classic_deprecated_method()
- obj.foo3()
- assert len(warns) == 1
- warn = warns[0]
- assert issubclass(warn.category, DeprecationWarning)
- assert "deprecated method" in str(warn.message)
- assert warn.filename == __file__, 'Incorrect warning stackLevel'
-
-
-# noinspection PyShadowingNames
-def test_classic_deprecated_static_method__warns(classic_deprecated_static_method):
- with warnings.catch_warnings(record=True) as warns:
- warnings.simplefilter("always")
- classic_deprecated_static_method()
- assert len(warns) == 1
- warn = warns[0]
- assert issubclass(warn.category, DeprecationWarning)
- assert "deprecated function (or staticmethod)" in str(warn.message)
- assert warn.filename == __file__, 'Incorrect warning stackLevel'
-
-
-# noinspection PyShadowingNames
-def test_classic_deprecated_class_method__warns(classic_deprecated_class_method):
- with warnings.catch_warnings(record=True) as warns:
- warnings.simplefilter("always")
- cls = classic_deprecated_class_method()
- cls.foo5()
- assert len(warns) == 1
- warn = warns[0]
- assert issubclass(warn.category, DeprecationWarning)
- if sys.version_info >= (3, 9):
- assert "deprecated class method" in str(warn.message)
- else:
- assert "deprecated function (or staticmethod)" in str(warn.message)
- assert warn.filename == __file__, 'Incorrect warning stackLevel'
-
-
-def test_should_raise_type_error():
- try:
- deprecated.classic.deprecated(5)
- assert False, "TypeError not raised"
- except TypeError:
- pass
-
-
-def test_warning_msg_has_reason():
- reason = "Good reason"
-
- @deprecated.classic.deprecated(reason=reason)
- def foo():
- pass
-
- with warnings.catch_warnings(record=True) as warns:
- foo()
- warn = warns[0]
- assert reason in str(warn.message)
-
-
-def test_warning_msg_has_version():
- version = "1.2.3"
-
- @deprecated.classic.deprecated(version=version)
- def foo():
- pass
-
- with warnings.catch_warnings(record=True) as warns:
- foo()
- warn = warns[0]
- assert version in str(warn.message)
-
-
-def test_warning_is_ignored():
- @deprecated.classic.deprecated(action='ignore')
- def foo():
- pass
-
- with warnings.catch_warnings(record=True) as warns:
- foo()
- assert len(warns) == 0
-
-
-def test_specific_warning_cls_is_used():
- @deprecated.classic.deprecated(category=MyDeprecationWarning)
- def foo():
- pass
-
- with warnings.catch_warnings(record=True) as warns:
- foo()
- warn = warns[0]
- assert issubclass(warn.category, MyDeprecationWarning)
-
-
-def test_respect_global_filter():
- @deprecated.classic.deprecated(version='1.2.1', reason="deprecated function")
- def fun():
- print("fun")
-
- warnings.simplefilter("once", category=DeprecationWarning)
-
- with warnings.catch_warnings(record=True) as warns:
- fun()
- fun()
- assert len(warns) == 1
+ return Foo.foo
+
+ def test_deprecated_function(self):
+ foo = self._get_deprecated_func()
+ with warnings.catch_warnings(record=True) as w:
+ warnings.simplefilter("always")
+ foo()
+ self.assertEqual(len(w), 1)
+ self.assertTrue(issubclass(w[-1].category, DeprecationWarning))
+ self.assertIn("Function foo is deprecated.", str(w[-1].message))
+
+ def test_deprecated_class(self):
+ Foo = self._get_deprecated_class()
+ with warnings.catch_warnings(record=True) as w:
+ warnings.simplefilter("always")
+ Foo()
+ self.assertEqual(len(w), 1)
+ self.assertTrue(issubclass(w[-1].category, DeprecationWarning))
+ self.assertIn("Class Foo is deprecated.", str(w[-1].message))
+
+ def test_deprecated_method(self):
+ Foo = self._get_deprecated_method()
+ foo = Foo()
+ with warnings.catch_warnings(record=True) as w:
+ warnings.simplefilter("always")
+ foo.foo()
+ self.assertEqual(len(w), 1)
+ self.assertTrue(issubclass(w[-1].category, DeprecationWarning))
+ self.assertIn("Method foo is deprecated.", str(w[-1].message))
+
+ def test_deprecated_static_method(self):
+ foo = self._get_deprecated_static_method()
+ with warnings.catch_warnings(record=True) as w:
+ warnings.simplefilter("always")
+ foo()
+ self.assertEqual(len(w), 1)
+ self.assertTrue(issubclass(w[-1].category, DeprecationWarning))
+ self.assertIn("Function foo is deprecated.", str(w[-1].message))
+
+ def test_deprecated_with_reason(self):
+ foo = self._get_deprecated_func(reason="Good reason")
+ with warnings.catch_warnings(record=True) as w:
+ warnings.simplefilter("always")
+ foo()
+ self.assertEqual(len(w), 1)
+ self.assertTrue(issubclass(w[-1].category, DeprecationWarning))
+ self.assertIn("Function foo is deprecated. Good reason", str(w[-1].message))
+
+ def test_deprecated_with_version(self):
+ foo = self._get_deprecated_func(version="1.2.3")
+ with warnings.catch_warnings(record=True) as w:
+ warnings.simplefilter("always")
+ foo()
+ self.assertEqual(len(w), 1)
+ self.assertTrue(issubclass(w[-1].category, DeprecationWarning))
+ self.assertIn("Function foo is deprecated. -- Deprecated since version 1.2.3.", str(w[-1].message))
+
+ def test_deprecated_with_custom_warning(self):
+ foo = self._get_deprecated_func(category=MyDeprecationWarning)
+ with warnings.catch_warnings(record=True) as w:
+ warnings.simplefilter("always")
+ foo()
+ self.assertEqual(len(w), 1)
+ self.assertTrue(issubclass(w[-1].category, MyDeprecationWarning))
+
+
+if __name__ == '__main__':
+ unittest.main()