[Git][debian-gis-team/python-deprecated][master] 5 commits: New upstream version 1.2.11
Bas Couwenberg
gitlab at salsa.debian.org
Sun Jan 17 12:29:04 GMT 2021
Bas Couwenberg pushed to branch master at Debian GIS Project / python-deprecated
Commits:
7fe4a8ab by Bas Couwenberg at 2021-01-17T13:19:23+01:00
New upstream version 1.2.11
- - - - -
02bd6932 by Bas Couwenberg at 2021-01-17T13:19:30+01:00
Update upstream source from tag 'upstream/1.2.11'
Update to upstream version '1.2.11'
with Debian dir 96c9fd4834df8d6be6b2958124b8ea29ddcf6aa3
- - - - -
e23c55ba by Bas Couwenberg at 2021-01-17T13:20:46+01:00
New upstream release.
- - - - -
e632c2f9 by Bas Couwenberg at 2021-01-17T13:22:37+01:00
Drop patches, included upstream.
- - - - -
e3b480ca by Bas Couwenberg at 2021-01-17T13:22:59+01:00
Set distribution to unstable.
- - - - -
24 changed files:
- .bumpversion.cfg
- + .github/workflows/python-package.yml
- .packit.yml
- .travis.yml
- CHANGELOG.rst
- debian/changelog
- − debian/patches/0001-Update-expected-class-method-deprecation-msgs-in-tes.patch
- − debian/patches/series
- deprecated/__init__.py
- deprecated/classic.py
- deprecated/sphinx.py
- docs/source/_static/banner.png
- docs/source/conf.py
- docs/source/installation.rst
- docs/source/sphinx/calc_mean.py
- docs/source/sphinx/calc_mean_deco.py
- docs/source/sphinx_deco.rst
- pyproject.toml
- python-deprecated.spec
- setup.py
- tests/test_deprecated.py
- tests/test_sphinx.py
- + tests/test_sphinx_adapter.py
- tox.ini
Changes:
=====================================
.bumpversion.cfg
=====================================
@@ -1,5 +1,5 @@
[bumpversion]
-current_version = 1.2.10
+current_version = 1.2.11
commit = True
tag = False
message = Prepare next version {new_version} (unreleased)
=====================================
.github/workflows/python-package.yml
=====================================
@@ -0,0 +1,57 @@
+# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
+# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
+
+name: Python package
+
+on:
+ push:
+ branches: [ master ]
+ pull_request:
+ branches: [ master ]
+
+jobs:
+ pytest-py27-p35:
+ runs-on: ${{ matrix.platform }}
+
+ strategy:
+ matrix:
+ platform: [ ubuntu-latest, macos-latest, windows-latest ]
+ python-version: [ 2.7, 3.5 ]
+
+ steps:
+ - uses: actions/checkout at v2
+ - name: Set up Python ${{ matrix.python-version }}
+ uses: actions/setup-python at v2
+ with:
+ python-version: ${{ matrix.python-version }}
+ - name: Install dependencies
+ run: |
+ python -m pip install --upgrade 'pip < 21'
+ python -m pip install 'PyTest < 5'
+ python -m pip install -e .
+ - name: Test with pytest
+ run: |
+ pytest tests/
+
+ pytest-py36-py39:
+ runs-on: ${{ matrix.platform }}
+
+ strategy:
+ matrix:
+ platform: [ ubuntu-latest, macos-latest, windows-latest ]
+ python-version: [ 3.6, 3.7, 3.8, 3.9 ]
+
+ steps:
+ - uses: actions/checkout at v2
+ - name: Set up Python ${{ matrix.python-version }}
+ uses: actions/setup-python at v2
+ with:
+ python-version: ${{ matrix.python-version }}
+ - name: Install dependencies
+ run: |
+ python -m pip install --upgrade pip
+ python -m pip install 'PyTest'
+ python -m pip install -e .
+ - name: Test with pytest
+ run: |
+ pytest tests/
=====================================
.packit.yml
=====================================
@@ -1,32 +1,17 @@
-specfile_path: python-deprecated.spec
synced_files:
- python-deprecated.spec
- .packit.yml
-upstream_project_name: Deprecated
+upstream_package_name: Deprecated
+upstream_tag_template: v{version}
downstream_package_name: python-deprecated
-create_pr: false
jobs:
- - job: propose_downstream
- trigger: release
- metadata:
- dist-git-branch: master
- - job: propose_downstream
- trigger: release
- metadata:
- dist-git-branch: fedora-all
- - job: propose_downstream
- trigger: release
- metadata:
- dist-git-branch: f30
- - job: propose_downstream
- trigger: release
- metadata:
- dist-git-branch: f29
- - job: copr_build
- trigger: pull_request
- metadata:
- targets:
- - fedora-all
- - fedora-30-x86_64
- - fedora-29-x86_64
- - fedora-rawhide-x86_64
+- job: propose_downstream
+ trigger: release
+ metadata:
+ dist_git_branches:
+ - fedora-all
+- job: copr_build
+ trigger: pull_request
+ metadata:
+ targets:
+ - fedora-all
=====================================
.travis.yml
=====================================
@@ -1,3 +1,6 @@
+arch:
+ - amd64
+ - ppc64le
language: python
python:
- "2.7"
@@ -9,8 +12,19 @@ python:
- "pypy"
- "pypy3"
jobs:
- allow_failures:
+ exclude:
+ - arch: ppc64le
+ python: "2.7"
+ - arch: ppc64le
+ python: "pypy"
+ - arch: ppc64le
+ python: "pypy3"
+ - arch: amd64
+ python: "pypy"
+
+allow_failures:
- python: "3.9-dev"
+
install:
- pip install coveralls tox-travis
script:
=====================================
CHANGELOG.rst
=====================================
@@ -18,6 +18,38 @@ and this project adheres to `Semantic Versioning <https://semver.org/spec/v2.0.0
(only in comment or documentation).
+v1.2.11 (2021-01-17)
+====================
+
+Bug fix release
+
+Fix
+---
+
+- Fix packit configuration: use ``upstream_tag_template: v{version}``.
+
+- Fix #33: Change the class :class:`~deprecated.sphinx.SphinxAdapter`:
+ add the ``line_length`` keyword argument to the constructor to specify the max line length of the directive text.
+ Sphinx decorators also accept the ``line_length`` argument.
+
+- Fix #34: ``versionadded`` and ``versionchanged`` decorators don't emit ``DeprecationWarning``
+ anymore on decorated classes.
+
+
+Other
+-----
+
+- Change the Tox configuration to run tests on Python 2.7, Python 3.4 and above (and PyPy 2.7 & 3.6).
+
+- Update the classifiers in ``setup.py``.
+
+- Replace ``bumpversion`` by `bump2version <https://pypi.org/project/bump2version/>`_ in ``setup.py`` and documentation.
+
+- Update configuration for Black and iSort.
+
+- Fix the development requirement versions in ``setup.py`` for Python 2.7 EOL.
+
+
v1.2.10 (2020-05-13)
====================
=====================================
debian/changelog
=====================================
@@ -1,9 +1,11 @@
-python-deprecated (1.2.10-3) UNRELEASED; urgency=medium
+python-deprecated (1.2.11-1) unstable; urgency=medium
+ * New upstream release.
* Bump watch file version to 4.
* Bump Standards-Version to 4.5.1, no changes.
+ * Drop patches, included upstream.
- -- Bas Couwenberg <sebastic at debian.org> Fri, 06 Nov 2020 19:51:36 +0100
+ -- Bas Couwenberg <sebastic at debian.org> Sun, 17 Jan 2021 13:22:51 +0100
python-deprecated (1.2.10-2) unstable; urgency=medium
=====================================
debian/patches/0001-Update-expected-class-method-deprecation-msgs-in-tes.patch deleted
=====================================
@@ -1,43 +0,0 @@
-Description: Update expected class method deprecation msgs in tests for py3.9
- Python 3.9 has fixed @classmethod combining with other decorators,
- making deprecated correctly report 'class method' (instead of function
- or static method). Update the tests to account for that.
-Author: Michał Górny <mgorny at gentoo.org>
-Origin: https://github.com/tantale/deprecated/commit/efb3e60623e1dda88c2725a93223d290924e8666
-Bug: https://github.com/tantale/deprecated/issues/29
-Bug-Debian: https://bugs.debian.org/973164
-
---- a/tests/test_deprecated.py
-+++ b/tests/test_deprecated.py
-@@ -1,4 +1,5 @@
- # -*- coding: utf-8 -*-
-+import sys
- import warnings
-
- import pytest
-@@ -184,7 +185,10 @@ def test_classic_deprecated_class_method
- assert len(warns) == 1
- warn = warns[0]
- assert issubclass(warn.category, DeprecationWarning)
-- assert "deprecated function (or staticmethod)" in str(warn.message)
-+ 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'
-
-
---- a/tests/test_sphinx.py
-+++ b/tests/test_sphinx.py
-@@ -334,7 +334,10 @@ def test_sphinx_deprecated_class_method_
- assert len(warns) == 1
- warn = warns[0]
- assert issubclass(warn.category, DeprecationWarning)
-- assert "deprecated function (or staticmethod)" in str(warn.message)
-+ if sys.version_info >= (3, 9):
-+ assert "deprecated class method" in str(warn.message)
-+ else:
-+ assert "deprecated function (or staticmethod)" in str(warn.message)
-
-
- def test_should_raise_type_error():
=====================================
debian/patches/series deleted
=====================================
@@ -1 +0,0 @@
-0001-Update-expected-class-method-deprecation-msgs-in-tes.patch
=====================================
deprecated/__init__.py
=====================================
@@ -7,7 +7,9 @@ Python ``@deprecated`` decorator to deprecate old python classes, functions or m
"""
-#: Module Version Number, see `PEP 396 <https://www.python.org/dev/peps/pep-0396/>`_.
-__version__ = "1.2.10"
+__version__ = "1.2.11"
+__author__ = u"Laurent LAPORTE <tantale.solutions at gmail.com>"
+__date__ = "2021-01-17"
+__credits__ = "(c) Laurent LAPORTE"
from deprecated.classic import deprecated
=====================================
deprecated/classic.py
=====================================
@@ -9,8 +9,8 @@ Classic ``@deprecated`` decorator to deprecate old python classes, functions or
"""
import functools
import inspect
-import warnings
import platform
+import warnings
import wrapt
=====================================
deprecated/sphinx.py
=====================================
@@ -19,6 +19,7 @@ to the docstring of your function and classes.
Of course, the ``@deprecated`` decorator will emit a deprecation warning
when the function/method is called or the class is constructed.
"""
+import re
import textwrap
import wrapt
@@ -40,7 +41,15 @@ class SphinxAdapter(ClassicAdapter):
- The reason message is obviously added in the directive block if not empty.
"""
- def __init__(self, directive, reason="", version="", action=None, category=DeprecationWarning):
+ def __init__(
+ self,
+ directive,
+ reason="",
+ version="",
+ action=None,
+ category=DeprecationWarning,
+ line_length=70,
+ ):
"""
Construct a wrapper adapter.
@@ -70,8 +79,13 @@ class SphinxAdapter(ClassicAdapter):
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.
+
+ :type line_length: int
+ :param line_length:
+ Max line length of the directive text. If non nul, a long text is wrapped in several lines.
"""
self.directive = directive
+ self.line_length = line_length
super(SphinxAdapter, self).__init__(reason=reason, version=version, action=action, category=category)
def __call__(self, wrapped):
@@ -82,24 +96,40 @@ class SphinxAdapter(ClassicAdapter):
:return: the decorated class or function.
"""
+ # -- build the directive division
+ fmt = ".. {directive}:: {version}" if self.version else ".. {directive}::"
+ div_lines = [fmt.format(directive=self.directive, version=self.version)]
+ width = self.line_length - 3 if self.line_length > 3 else 2 ** 16
reason = textwrap.dedent(self.reason).strip()
- reason = '\n'.join(
- textwrap.fill(line, width=70, initial_indent=' ', subsequent_indent=' ') for line in reason.splitlines()
- ).strip()
+ for paragraph in reason.splitlines():
+ if paragraph:
+ div_lines.extend(
+ textwrap.fill(
+ paragraph,
+ width=width,
+ initial_indent=" ",
+ subsequent_indent=" ",
+ ).splitlines()
+ )
+ else:
+ div_lines.append("")
+
+ # -- get the docstring, normalize the trailing newlines
docstring = textwrap.dedent(wrapped.__doc__ or "")
if docstring:
- docstring += "\n\n"
- if self.version:
- docstring += ".. {directive}:: {version}\n".format(directive=self.directive, version=self.version)
- else:
- docstring += ".. {directive}::\n".format(directive=self.directive)
- if reason:
- docstring += " {reason}\n".format(reason=reason)
+ # An empty line must separate the original docstring and the directive.
+ docstring = re.sub(r"\n+$", "", docstring, flags=re.DOTALL) + "\n\n"
+
+ # -- append the directive division to the docstring
+ docstring += "".join("{}\n".format(line) for line in div_lines)
+
wrapped.__doc__ = docstring
+ if self.directive in {"versionadded", "versionchanged"}:
+ return wrapped
return super(SphinxAdapter, self).__call__(wrapped)
-def versionadded(reason="", version=""):
+def versionadded(reason="", version="", line_length=70):
"""
This decorator can be used to insert a "versionadded" directive
in your function/class docstring in order to documents the
@@ -114,9 +144,18 @@ def versionadded(reason="", version=""):
the version number has the format "MAJOR.MINOR.PATCH", and,
in the case of a new functionality, the "PATCH" component should be "0".
+ :type line_length: int
+ :param line_length:
+ Max line length of the directive text. If non nul, a long text is wrapped in several lines.
+
:return: the decorated function.
"""
- adapter = SphinxAdapter('versionadded', reason=reason, version=version)
+ adapter = SphinxAdapter(
+ 'versionadded',
+ reason=reason,
+ version=version,
+ line_length=line_length,
+ )
# noinspection PyUnusedLocal
@wrapt.decorator(adapter=adapter)
@@ -126,7 +165,7 @@ def versionadded(reason="", version=""):
return wrapper
-def versionchanged(reason="", version=""):
+def versionchanged(reason="", version="", line_length=70):
"""
This decorator can be used to insert a "versionchanged" directive
in your function/class docstring in order to documents the
@@ -140,9 +179,18 @@ def versionchanged(reason="", version=""):
If you follow the `Semantic Versioning <https://semver.org/>`_,
the version number has the format "MAJOR.MINOR.PATCH".
+ :type line_length: int
+ :param line_length:
+ Max line length of the directive text. If non nul, a long text is wrapped in several lines.
+
:return: the decorated function.
"""
- adapter = SphinxAdapter('versionchanged', reason=reason, version=version)
+ adapter = SphinxAdapter(
+ 'versionchanged',
+ reason=reason,
+ version=version,
+ line_length=line_length,
+ )
# noinspection PyUnusedLocal
@wrapt.decorator(adapter=adapter)
@@ -178,6 +226,9 @@ def deprecated(*args, **kwargs):
By default, the category class is :class:`~DeprecationWarning`,
you can inherit this class to define your own deprecation warning category.
+ - "line_length":
+ Max line length of the directive text. If non nul, a long text is wrapped in several lines.
+
:return: the decorated function.
"""
directive = kwargs.pop('directive', 'deprecated')
=====================================
docs/source/_static/banner.png
=====================================
Binary files a/docs/source/_static/banner.png and b/docs/source/_static/banner.png differ
=====================================
docs/source/conf.py
=====================================
@@ -61,7 +61,7 @@ author = 'Marcos CARDOSO & Laurent LAPORTE'
# built documents.
#
# The full version, including alpha/beta/rc tags.
-release = "1.2.10"
+release = "1.2.11"
# The short X.Y version.
version = release.rpartition('.')[0]
=====================================
docs/source/installation.rst
=====================================
@@ -28,7 +28,7 @@ You need to install them explicitly with `pip install -e .[dev]`.
* `pytest-cov`_ is a `pytest`_ plugin used to produce coverage reports..
* `tox`_ aims to automate and standardize testing in Python.
It is part of a larger vision of easing the packaging, testing and release process of Python software…
-* `bumpversion`_ is a small command line tool to simplify releasing software
+* `bump2version`_ is a small command line tool to simplify releasing software
by updating all version strings in your source code by the correct increment.
Also creates commits and tags…
* `sphinx`_ is a tool that makes it easy to create intelligent and beautiful documentation.
@@ -36,7 +36,7 @@ You need to install them explicitly with `pip install -e .[dev]`.
.. _pytest: https://docs.pytest.org/en/latest/
.. _pytest-cov: http://pytest-cov.readthedocs.io/en/latest/
.. _tox: https://tox.readthedocs.io/en/latest/
-.. _bumpversion: https://github.com/peritus/bumpversion
+.. _bump2version: https://github.com/c4urself/bump2version
.. _sphinx: http://www.sphinx-doc.org/en/stable/index.html
=====================================
docs/source/sphinx/calc_mean.py
=====================================
@@ -2,7 +2,7 @@ def mean(values):
"""
Compute the arithmetic mean (“average”) of values.
- :type values: list[float]
+ :type values: typing.List[float]
:param values: List of floats
:return: Mean of values.
=====================================
docs/source/sphinx/calc_mean_deco.py
=====================================
@@ -9,7 +9,7 @@ def mean(values):
"""
Compute the arithmetic mean (“average”) of values.
- :type values: list[float]
+ :type values: typing.List[float]
:param values: List of floats
:return: Mean of values.
"""
=====================================
docs/source/sphinx_deco.rst
=====================================
@@ -61,7 +61,7 @@ The documentation of the *mean()* function looks like this:
Compute the arithmetic mean (“average”) of values.
- :type values: list[float]
+ :type values: typing.List[float]
:param values: List of floats
:return: Mean of values.
=====================================
pyproject.toml
=====================================
@@ -3,3 +3,7 @@ line-length = 120
skip-string-normalization = true
target-version = ['py27', 'py34', 'py35', 'py36', 'py37', 'py38']
include = '\.pyi?$'
+
+[tool.isort]
+line_length = 120
+force_single_line = true
=====================================
python-deprecated.spec
=====================================
@@ -2,12 +2,12 @@
%global pkgname deprecated
Name: python-%{pkgname}
-Version: 1.2.10
+Version: 1.2.11
Release: 2%{?dist}
Summary: Python decorator to deprecate old python classes, functions or methods
License: MIT
URL: https://github.com/tantale/%{pkgname}
-Source0: https://files.pythonhosted.org/packages/source/D/%{srcname}/%{srcname}-%{version}.tar.gz
+Source0: %{pypi_source}
BuildArch: noarch
%description
@@ -38,7 +38,7 @@ rm -rf %{pkgname}.egg-info
%license LICENSE.rst
%doc README.md
%{python3_sitelib}/%{pkgname}/
-%{python3_sitelib}/%{srcname}-%{version}-*.egg-info/
+%{python3_sitelib}/%{srcname}-*.egg-info/
%changelog
=====================================
setup.py
=====================================
@@ -143,7 +143,7 @@ from setuptools import setup
setup(
name='Deprecated',
- version='1.2.10',
+ version='1.2.11',
url='https://github.com/tantale/deprecated',
project_urls={
"Documentation": "https://deprecated.readthedocs.io/en/latest/",
@@ -176,17 +176,25 @@ setup(
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
+ 'Programming Language :: Python :: 3.8',
+ 'Programming Language :: Python :: 3.9',
'Topic :: Software Development :: Libraries :: Python Modules',
],
extras_require={
'dev': [
'tox',
'PyTest ; python_version >= "3.6"',
- 'PyTest < 5 ; python_version < "3"',
+ 'PyTest < 5 ; python_version < "3.6"',
'PyTest-Cov ; python_version >= "3.6"',
- 'PyTest-Cov < 2.6 ; python_version < "3"',
- 'bumpversion < 1',
+ 'PyTest-Cov < 2.6 ; python_version < "3.6"',
+ 'bump2version < 1',
'sphinx < 2',
+ # Python 2.7 EOL:
+ 'importlib-metadata < 3 ; python_version < "3"',
+ 'importlib-resources < 4 ; python_version < "3"',
+ 'configparser < 5 ; python_version < "3"',
+ 'sphinxcontrib-websupport < 2 ; python_version < "3"',
+ 'zipp < 2 ; python_version < "3"',
]
},
python_requires='>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*',
=====================================
tests/test_deprecated.py
=====================================
@@ -1,4 +1,5 @@
# -*- coding: utf-8 -*-
+import sys
import warnings
import pytest
@@ -184,7 +185,10 @@ def test_classic_deprecated_class_method__warns(classic_deprecated_class_method)
assert len(warns) == 1
warn = warns[0]
assert issubclass(warn.category, DeprecationWarning)
- assert "deprecated function (or staticmethod)" in str(warn.message)
+ 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'
=====================================
tests/test_sphinx.py
=====================================
@@ -24,6 +24,7 @@ import deprecated.sphinx
:return: sum = *x* + *y*
""",
],
+ ids=["no_docstring", "short_docstring", "long_docstring"]
)
def docstring(request):
return request.param
@@ -68,6 +69,7 @@ def directive(request):
),
),
],
+ ids=["reason&version", "version", "reason"]
)
def test_has_sphinx_docstring(docstring, directive, reason, version, expected):
# The function:
@@ -93,6 +95,16 @@ def test_has_sphinx_docstring(docstring, directive, reason, version, expected):
if current:
assert re.search("\n[ ]*\n$", current, flags=re.DOTALL)
+ with warnings.catch_warnings(record=True) as warns:
+ foo(1, 2)
+
+ if directive in {'versionadded', 'versionchanged'}:
+ # don't emit DeprecationWarning
+ assert len(warns) == 0
+ else:
+ # emit DeprecationWarning
+ assert len(warns) == 1
+
# noinspection PyShadowingNames
@pytest.mark.skipif(
@@ -131,6 +143,7 @@ def test_has_sphinx_docstring(docstring, directive, reason, version, expected):
),
),
],
+ ids=["reason&version", "version", "reason"]
)
def test_cls_has_sphinx_docstring(docstring, directive, reason, version, expected):
# The class:
@@ -156,6 +169,16 @@ def test_cls_has_sphinx_docstring(docstring, directive, reason, version, expecte
if current:
assert re.search("\n[ ]*\n$", current, flags=re.DOTALL)
+ with warnings.catch_warnings(record=True) as warns:
+ Foo()
+
+ if directive in {'versionadded', 'versionchanged'}:
+ # don't emit DeprecationWarning
+ assert len(warns) == 0
+ else:
+ # emit DeprecationWarning
+ assert len(warns) == 1
+
class MyDeprecationWarning(DeprecationWarning):
pass
@@ -334,7 +357,10 @@ def test_sphinx_deprecated_class_method__warns(sphinx_deprecated_class_method):
assert len(warns) == 1
warn = warns[0]
assert issubclass(warn.category, DeprecationWarning)
- assert "deprecated function (or staticmethod)" in str(warn.message)
+ if sys.version_info >= (3, 9):
+ assert "deprecated class method" in str(warn.message)
+ else:
+ assert "deprecated function (or staticmethod)" in str(warn.message)
def test_should_raise_type_error():
=====================================
tests/test_sphinx_adapter.py
=====================================
@@ -0,0 +1,128 @@
+# coding: utf-8
+import textwrap
+
+import pytest
+
+from deprecated.sphinx import SphinxAdapter
+from deprecated.sphinx import deprecated
+from deprecated.sphinx import versionadded
+from deprecated.sphinx import versionchanged
+
+
+ at pytest.mark.parametrize(
+ "line_length, expected",
+ [
+ (
+ 50,
+ textwrap.dedent(
+ """
+ Description of foo
+
+ :return: nothing
+
+ .. {directive}:: 1.2.3
+ foo has changed in this version
+
+ bar bar bar bar bar bar bar bar bar bar bar
+ bar bar bar bar bar bar bar bar bar bar bar
+ bar
+ """
+ ),
+ ),
+ (
+ 0,
+ textwrap.dedent(
+ """
+ Description of foo
+
+ :return: nothing
+
+ .. {directive}:: 1.2.3
+ foo has changed in this version
+
+ bar bar bar bar bar bar bar bar bar bar bar bar bar bar bar bar bar bar bar bar bar bar bar
+ """
+ ),
+ ),
+ ],
+ ids=["wrapped", "long"],
+)
+ at pytest.mark.parametrize("directive", ["versionchanged", "versionadded", "deprecated"])
+def test_sphinx_adapter(directive, line_length, expected):
+ lines = [
+ "foo has changed in this version",
+ "", # newline
+ "bar " * 23, # long line
+ "", # trailing newline
+ ]
+ reason = "\n".join(lines)
+ adapter = SphinxAdapter(directive, reason=reason, version="1.2.3", line_length=line_length)
+
+ def foo():
+ """
+ Description of foo
+
+ :return: nothing
+ """
+
+ wrapped = adapter.__call__(foo)
+ expected = expected.format(directive=directive)
+ assert wrapped.__doc__ == expected
+
+
+ at pytest.mark.parametrize("directive", ["versionchanged", "versionadded", "deprecated"])
+def test_sphinx_adapter__empty_docstring(directive):
+ lines = [
+ "foo has changed in this version",
+ "", # newline
+ "bar " * 23, # long line
+ "", # trailing newline
+ ]
+ reason = "\n".join(lines)
+ adapter = SphinxAdapter(directive, reason=reason, version="1.2.3", line_length=50)
+
+ def foo():
+ pass
+
+ wrapped = adapter.__call__(foo)
+ expected = textwrap.dedent(
+ """\
+ .. {directive}:: 1.2.3
+ foo has changed in this version
+
+ bar bar bar bar bar bar bar bar bar bar bar
+ bar bar bar bar bar bar bar bar bar bar bar
+ bar
+ """
+ )
+ expected = expected.format(directive=directive)
+ assert wrapped.__doc__ == expected
+
+
+ at 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)
+
+ expected = textwrap.dedent(
+ """\
+ .. {directive}:: 1.2.3
+ bar bar bar bar bar bar bar bar bar bar bar
+ bar bar bar bar bar bar bar bar bar bar bar
+ bar bar bar bar bar bar bar bar
+ """
+ )
+ expected = expected.format(directive=directive)
+ assert foo.__doc__ == expected
=====================================
tox.ini
=====================================
@@ -11,17 +11,17 @@
# - /usr/local/bin/pypy -> /opt/pypy2.7-v7.3.0-osx64/bin/pypy
# - /usr/local/bin/pypy3 -> /opt/pypy3.6-v7.3.0-osx64/bin/pypy3
envlist =
- py{27,35,36,37,38,39}-wrapt{1.10,1.11,1.12}
+ py{27,34,35,36,37,38,39}-wrapt{1.10,1.11,1.12}
pypy, pypy3
docs
[testenv]
commands = pytest --cov-report term-missing --cov=deprecated tests/
deps =
- py27,py35: pip >= 9.0.3, < 19.2
- py27: PyTest < 5
+ py27,py34,py35: pip >= 9.0.3, < 19.2
+ py27,py34: PyTest < 5
py35,py36,py37,py38,pypy,pypy3: PyTest
- py27: PyTest-Cov < 2.6
+ py27,py34: PyTest-Cov < 2.6
py35,py36,py37,py38,py39,pypy,pypy3: PyTest-Cov
wrapt1.10: wrapt ~= 1.10.0
wrapt1.11: wrapt ~= 1.11.0
View it on GitLab: https://salsa.debian.org/debian-gis-team/python-deprecated/-/compare/eb7309a8a4c2251ddf8635f0844e98ac97610a40...e3b480ca81d4fb1b31835770740f42d2a8eedb59
--
View it on GitLab: https://salsa.debian.org/debian-gis-team/python-deprecated/-/compare/eb7309a8a4c2251ddf8635f0844e98ac97610a40...e3b480ca81d4fb1b31835770740f42d2a8eedb59
You're receiving this email because of your account on salsa.debian.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/pkg-grass-devel/attachments/20210117/375b7b3d/attachment-0001.html>
More information about the Pkg-grass-devel
mailing list