Hello community, here is the log from the commit of package python-semver for openSUSE:Factory checked in at 2020-07-20 21:00:12 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-semver (Old) and /work/SRC/openSUSE:Factory/.python-semver.new.3592 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-semver" Mon Jul 20 21:00:12 2020 rev:13 rq:821766 version:2.10.2 Changes: -------- --- /work/SRC/openSUSE:Factory/python-semver/python-semver.changes 2020-05-19 14:58:39.457423749 +0200 +++ /work/SRC/openSUSE:Factory/.python-semver.new.3592/python-semver.changes 2020-07-20 21:01:32.209102987 +0200 @@ -1,0 +2,21 @@ +Sun Jul 12 16:04:41 UTC 2020 - Sebastian Wagner <[email protected]> + +- update to version 2.10.2: + - Features: + - Increase coverage + - Bug Fixes: + - Fixed ``__getitem__`` returning None on wrong parts + - Doc: Add missing "install" subcommand for openSUSE + - Deprecations: + - functions `semver.max_ver`, `semver.min_ver` +- update to version 2.10.1: + - Features: + - Added release policy and version restriction in documentation to + help our users which would like to stay on the major 2 release. + - Simplified installation semver on openSUSE with ``obs://``. + - Made docstrings consistent + - Bug Fixes: + - Fixed return type of ``semver.VersionInfo.next_version`` + to always return a ``VersionInfo`` instance. + +------------------------------------------------------------------- Old: ---- semver-2.10.0.tar.gz New: ---- semver-2.10.2.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-semver.spec ++++++ --- /var/tmp/diff_new_pack.lJ5oGG/_old 2020-07-20 21:01:36.313107148 +0200 +++ /var/tmp/diff_new_pack.lJ5oGG/_new 2020-07-20 21:01:36.317107151 +0200 @@ -19,7 +19,7 @@ %{?!python_module:%define python_module() python-%{**} python3-%{**}} %bcond_without test Name: python-semver -Version: 2.10.0 +Version: 2.10.2 Release: 0 Summary: Python helper for Semantic Versioning License: BSD-3-Clause ++++++ semver-2.10.0.tar.gz -> semver-2.10.2.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/semver-2.10.0/CHANGELOG.rst new/semver-2.10.2/CHANGELOG.rst --- old/semver-2.10.0/CHANGELOG.rst 2020-05-05 20:31:58.000000000 +0200 +++ new/semver-2.10.2/CHANGELOG.rst 2020-06-15 20:33:06.000000000 +0200 @@ -6,6 +6,62 @@ All notable changes to this code base will be documented in this file, in every released version. + +Version 2.10.2 +============== + +:Released: 2020-06-15 +:Maintainer: Tom Schraitle + +Features +-------- + +:gh:`268`: Increase coverage + + +Bug Fixes +--------- + +:gh:`260` (:pr:`261`): Fixed ``__getitem__`` returning None on wrong parts +:pr:`263`: Doc: Add missing "install" subcommand for openSUSE + + +Additions +--------- + +n/a + +Deprecations +-------- + +* :gh:`160` (:pr:`264`): + * :func:`semver.max_ver` + * :func:`semver.min_ver` + + +Version 2.10.1 +============== + +:Released: 2020-05-13 +:Maintainer: Tom Schraitle + + +Features +-------- + +* :pr:`249`: Added release policy and version restriction in documentation to + help our users which would like to stay on the major 2 release. +* :pr:`250`: Simplified installation semver on openSUSE with ``obs://``. +* :pr:`256`: Made docstrings consistent + + +Bug Fixes +--------- + +* :gh:`251` (:pr:`254`): Fixed return type of ``semver.VersionInfo.next_version`` + to always return a ``VersionInfo`` instance. + + Version 2.10.0 ============== @@ -35,7 +91,7 @@ * :pr:`228`: Added better doctest integration -Removals +Deprecations -------- * :gh:`225` (:pr:`229`): Output a DeprecationWarning for the following functions: @@ -79,12 +135,6 @@ * :gh:`192` (:pr:`193`): Fixed "pysemver" and "pysemver bump" when called without arguments -Removals --------- - -not available - - Version 2.9.0 ============= :Released: 2019-10-30 @@ -124,7 +174,7 @@ Removals -------- -* :gh:`111` (:pr:`110`): Droped Python 3.3 +* :gh:`111` (:pr:`110`): Dropped Python 3.3 * :gh:`148` (:pr:`149`): Removed and replaced ``python setup.py test`` diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/semver-2.10.0/PKG-INFO new/semver-2.10.2/PKG-INFO --- old/semver-2.10.0/PKG-INFO 2020-05-05 20:37:20.000000000 +0200 +++ new/semver-2.10.2/PKG-INFO 2020-06-15 20:33:56.000000000 +0200 @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: semver -Version: 2.10.0 +Version: 2.10.2 Summary: Python helper for Semantic Versioning (http://semver.org/) Home-page: https://github.com/python-semver/python-semver Author: Kostiantyn Rybnikov diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/semver-2.10.0/docs/install.rst new/semver-2.10.2/docs/install.rst --- old/semver-2.10.0/docs/install.rst 2020-05-05 17:29:22.000000000 +0200 +++ new/semver-2.10.2/docs/install.rst 2020-06-10 09:28:03.000000000 +0200 @@ -1,6 +1,25 @@ Installing semver ================= +Release Policy +-------------- + +As semver uses `Semantic Versioning`_, breaking changes are only introduced in major +releases (incremented X in "X.Y.Z"). + +For users who want to stay with major 2 releases only, add the following version +restriction:: + + semver>=2,<3 + +This line avoids surprises. You will get any updates within the major 2 release like +2.9.1, 2.10.0, or above. However, you will never get an update for semver 3.0.0. + +Keep in mind, as this line avoids any major version updates, you also will never +get new exciting features or bug fixes. + +You can add this line in your file :file:`setup.py`, :file:`requirements.txt`, or any other +file that lists your dependencies. Pip --- @@ -17,12 +36,12 @@ pip3 install semver -If you want to install this specific version, you can use the command :command:`pip` -with an URL: +If you want to install this specific version (for example, 2.10.0), use the command :command:`pip` +with an URL and its version: .. parsed-literal:: - pip3 install git+https://github.com/python-semver/python-semver.git@|version| + pip3 install git+https://github.com/python-semver/[email protected] Linux Distributions @@ -84,13 +103,13 @@ openSUSE ^^^^^^^^ -1. Enable the the ``devel:languages:python`` repository on the Open Build Service (replace ``<VERSION>`` with the preferred openSUSE release):: +1. Enable the ``devel:languages:python`` repository of the Open Build Service:: - $ zypper addrepo https://download.opensuse.org/repositories/devel:/languages:/python/openSUSE_Leap_<VERSION>/devel:languages:python.repo + $ sudo zypper addrepo --refresh obs://devel:languages:python devel_languages_python 2. Install the package:: - $ zypper --repo devel_languages_python python3-semver + $ sudo zypper install --repo devel_languages_python python3-semver Ubuntu @@ -103,3 +122,6 @@ 2. Install the package:: $ sudo apt-get install python3-semver + + +.. _semantic versioning: http://semver.org/ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/semver-2.10.0/docs/usage.rst new/semver-2.10.2/docs/usage.rst --- old/semver-2.10.0/docs/usage.rst 2020-05-05 17:29:22.000000000 +0200 +++ new/semver-2.10.2/docs/usage.rst 2020-06-15 17:33:05.000000000 +0200 @@ -11,9 +11,9 @@ Knowing the Implemented semver.org Version ------------------------------------------ -The semver.org page is the authorative specification of how semantical -versioning is definied. -To know which version of semver.org is implemented in the semver libary, +The semver.org page is the authoritative specification of how semantic +versioning is defined. +To know which version of semver.org is implemented in the semver library, use the following constant:: >>> semver.SEMVER_SPEC_VERSION @@ -445,7 +445,11 @@ Other types cannot be compared. -If you need to convert some types into other, refer to :ref:`sec.convert.versions`. +If you need to convert some types into others, refer to :ref:`sec.convert.versions`. + +The use of these comparison operators also implies that you can use builtin +functions that leverage this capability; builtins including, but not limited to: :func:`max`, :func:`min` +(for examples, see :ref:`sec_max_min`) and :func:`sorted`. @@ -476,9 +480,47 @@ >>> semver.match("1.0.0", ">1.0.0") False +.. _sec_max_min: + +Getting Minimum and Maximum of Multiple Versions +------------------------------------------------ +.. versionchanged:: 2.10.2 + The functions :func:`semver.max_ver` and :func:`semver.min_ver` are deprecated in + favor of their builtin counterparts :func:`max` and :func:`min`. + +Since :class:`semver.VersionInfo` implements :func:`__gt__()` and :func:`__lt__()`, it can be used with builtins requiring + +.. code-block:: python + + >>> max([semver.VersionInfo(0, 1, 0), semver.VersionInfo(0, 2, 0), semver.VersionInfo(0, 1, 3)]) + VersionInfo(major=0, minor=2, patch=0, prerelease=None, build=None) + >>> min([semver.VersionInfo(0, 1, 0), semver.VersionInfo(0, 2, 0), semver.VersionInfo(0, 1, 3)]) + VersionInfo(major=0, minor=1, patch=0, prerelease=None, build=None) + +Incidentally, using :func:`map`, you can get the min or max version of any number of versions of the same type +(convertible to :class:`semver.VersionInfo`). + +For example, here are the maximum and minimum versions of a list of version strings: + +.. code-block:: python + + >>> str(max(map(semver.VersionInfo.parse, ['1.1.0', '1.2.0', '2.1.0', '0.5.10', '0.4.99']))) + '2.1.0' + >>> str(min(map(semver.VersionInfo.parse, ['1.1.0', '1.2.0', '2.1.0', '0.5.10', '0.4.99']))) + '0.4.99' + +And the same can be done with tuples: + +.. code-block:: python + + >>> max(map(lambda v: semver.VersionInfo(*v), [(1, 1, 0), (1, 2, 0), (2, 1, 0), (0, 5, 10), (0, 4, 99)])).to_tuple() + (2, 1, 0, None, None) + >>> min(map(lambda v: semver.VersionInfo(*v), [(1, 1, 0), (1, 2, 0), (2, 1, 0), (0, 5, 10), (0, 4, 99)])).to_tuple() + (0, 4, 99, None, None) -Getting Minimum and Maximum of two Versions -------------------------------------------- +For dictionaries, it is very similar to finding the max version tuple: see :ref:`sec.convert.versions`. + +The "old way" with :func:`semver.max_ver` or :func:`semver.min_ver` is still available, but not recommended: .. code-block:: python @@ -575,6 +617,28 @@ >>> s1 == s2 True +* :func:`semver.max_ver` + + Replace it with ``max(version1, version2, ...)`` or ``max([version1, version2, ...])``: + + .. code-block:: python + + >>> s1 = semver.max_ver("1.2.3", "1.2.4") + >>> s2 = str(max(map(semver.VersionInfo.parse, ("1.2.3", "1.2.4")))) + >>> s1 == s2 + True + +* :func:`semver.min_ver` + + Replace it with ``min(version1, version2, ...)`` or ``min([version1, version2, ...])``: + + .. code-block:: python + + >>> s1 = semver.min_ver("1.2.3", "1.2.4") + >>> s2 = str(min(map(semver.VersionInfo.parse, ("1.2.3", "1.2.4")))) + >>> s1 == s2 + True + * :func:`semver.parse` Replace it with :func:`semver.VersionInfo.parse` and diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/semver-2.10.0/release-procedure.md new/semver-2.10.2/release-procedure.md --- old/semver-2.10.0/release-procedure.md 2020-04-26 10:46:39.000000000 +0200 +++ new/semver-2.10.2/release-procedure.md 2020-05-14 10:11:44.000000000 +0200 @@ -1,54 +1,52 @@ -################# -Release procedure -################# +# Release Procedure -* Verify that issues about new release are closed https://github.com/python-semver/python-semver/issues and verify that no pull requests that should be included in this release haven't been left out https://github.com/python-semver/python-semver/pulls +1. Verify that issues about new release are closed https://github.com/python-semver/python-semver/issues and verify that no pull requests that should be included in this release haven't been left out https://github.com/python-semver/python-semver/pulls -* Verify that continuous integration for latest build was passing https://travis-ci.com/python-semver/python-semver +1. Verify that continuous integration for latest build was passing https://travis-ci.com/python-semver/python-semver -* Verify that `__version__` in [semver.py](https://github.com/python-semver/python-semver/blob/master/semver.py) have been updated and follow https://semver.org/ +1. Verify that `__version__` in [semver.py](https://github.com/python-semver/python-semver/blob/master/semver.py) have been updated and follow https://semver.org/ -* Verify that [CHANGELOG](https://github.com/python-semver/python-semver/blob/master/CHANGELOG.rst) have been updated. No WIP should be present in CHANGELOG during release! +1. Verify that [CHANGELOG](https://github.com/python-semver/python-semver/blob/master/CHANGELOG.rst) have been updated. No WIP should be present in CHANGELOG during release! -* If one or several supported Python versions have been removed or added, verify that the 3 following files have been updated: - * [setup.py](https://github.com/python-semver/python-semver/blob/master/setup.py) - * [tox.ini](https://github.com/python-semver/python-semver/blob/master/tox.ini) - * [.travis.yml](https://github.com/python-semver/python-semver/blob/master/.travis.yml) +1. If one or several supported Python versions have been removed or added, verify that the 3 following files have been updated: + * [setup.py](https://github.com/python-semver/python-semver/blob/master/setup.py) + * [tox.ini](https://github.com/python-semver/python-semver/blob/master/tox.ini) + * [.travis.yml](https://github.com/python-semver/python-semver/blob/master/.travis.yml) -* Verify that doc reflecting new changes have been updated and are available at https://python-semver.readthedocs.io/en/latest/ If necessary, trigger doc build at https://readthedocs.org/projects/python-semver/ +1. Verify that doc reflecting new changes have been updated and are available at https://python-semver.readthedocs.io/en/latest/ If necessary, trigger doc build at https://readthedocs.org/projects/python-semver/ -* Add eventually new contributor(s) to [CONTRIBUTORS](https://github.com/python-semver/python-semver/blob/master/CONTRIBUTORS) +1. Add eventually new contributor(s) to [CONTRIBUTORS](https://github.com/python-semver/python-semver/blob/master/CONTRIBUTORS) -* Ensure that long description (ie [README.rst](https://github.com/python-semver/python-semver/blob/master/README.rst)) can be correctly rendered by Pypi using `restview --long-description` +1. Ensure that long description (ie [README.rst](https://github.com/python-semver/python-semver/blob/master/README.rst)) can be correctly rendered by Pypi using `restview --long-description` -* Upload it to TestPyPI first: +1. Upload it to TestPyPI first: -```bash -git clean -xfd -python setup.py register sdist bdist_wheel --universal -twine upload --repository-url https://test.pypi.org/legacy/ dist/* -``` + ```bash + git clean -xfd + python setup.py sdist bdist_wheel --universal + twine upload --repository-url https://test.pypi.org/legacy/ dist/* + ``` - If you have a `~/.pypirc` with a `testpyi` section, the upload can be - simplified: + If you have a `~/.pypirc` with a `testpyi` section, the upload can be + simplified: - twine upload --repository testpyi dist/* + twine upload --repository testpyi dist/* -* Upload to PyPI +1. Upload to PyPI -```bash -git clean -xfd -python setup.py register sdist bdist_wheel --universal -twine upload dist/* -``` + ```bash + git clean -xfd + python setup.py register sdist bdist_wheel --universal + twine upload dist/* + ``` -* Go to https://pypi.org/project/semver/ to verify that new version is online and page is rendered correctly +1. Go to https://pypi.org/project/semver/ to verify that new version is online and page is rendered correctly -* Tag commit and push to github using command line interface +1. Tag commit and push to github using command line interface -```bash -git tag -a x.x.x -m 'Version x.x.x' -git push python-semver master --tags -``` + ```bash + git tag -a x.x.x -m 'Version x.x.x' + git push python-semver master --tags + ``` or using GitHub web interface available at https://github.com/python-semver/python-semver/releases diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/semver-2.10.0/semver.egg-info/PKG-INFO new/semver-2.10.2/semver.egg-info/PKG-INFO --- old/semver-2.10.0/semver.egg-info/PKG-INFO 2020-05-05 20:37:20.000000000 +0200 +++ new/semver-2.10.2/semver.egg-info/PKG-INFO 2020-06-15 20:33:56.000000000 +0200 @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: semver -Version: 2.10.0 +Version: 2.10.2 Summary: Python helper for Semantic Versioning (http://semver.org/) Home-page: https://github.com/python-semver/python-semver Author: Kostiantyn Rybnikov diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/semver-2.10.0/semver.py new/semver-2.10.2/semver.py --- old/semver-2.10.0/semver.py 2020-05-05 20:30:32.000000000 +0200 +++ new/semver-2.10.2/semver.py 2020-06-15 18:41:10.000000000 +0200 @@ -10,12 +10,44 @@ import warnings -__version__ = "2.10.0" +__version__ = "2.10.2" __author__ = "Kostiantyn Rybnikov" __author_email__ = "[email protected]" __maintainer__ = ["Sebastien Celles", "Tom Schraitle"] __maintainer_email__ = "[email protected]" +#: Our public interface +__all__ = ( + # + # Module level function: + "bump_build", + "bump_major", + "bump_minor", + "bump_patch", + "bump_prerelease", + "compare", + "deprecated", + "finalize_version", + "format_version", + "match", + "max_ver", + "min_ver", + "parse", + "parse_version_info", + "replace", + # + # CLI interface + "cmd_bump", + "cmd_check", + "cmd_compare", + "createparser", + "main", + "process", + # + # Constants and classes + "SEMVER_SPEC_VERSION", + "VersionInfo", +) #: Contains the implemented semver.org version of the spec SEMVER_SPEC_VERSION = "2.0.0" @@ -296,7 +328,7 @@ untouched. :return: new object with the raised major part - :rtype: VersionInfo + :rtype: :class:`VersionInfo` >>> ver = semver.VersionInfo.parse("3.4.5") >>> ver.bump_major() @@ -311,7 +343,7 @@ untouched. :return: new object with the raised minor part - :rtype: VersionInfo + :rtype: :class:`VersionInfo` >>> ver = semver.VersionInfo.parse("3.4.5") >>> ver.bump_minor() @@ -326,7 +358,7 @@ untouched. :return: new object with the raised patch part - :rtype: VersionInfo + :rtype: :class:`VersionInfo` >>> ver = semver.VersionInfo.parse("3.4.5") >>> ver.bump_patch() @@ -342,7 +374,7 @@ :param token: defaults to 'rc' :return: new object with the raised prerelease part - :rtype: str + :rtype: :class:`VersionInfo` >>> ver = semver.VersionInfo.parse("3.4.5-rc.1") >>> ver.bump_prerelease() @@ -360,7 +392,7 @@ :param token: defaults to 'build' :return: new object with the raised build part - :rtype: str + :rtype: :class:`VersionInfo` >>> ver = semver.VersionInfo.parse("3.4.5-rc.1+build.9") >>> ver.bump_build() @@ -439,7 +471,8 @@ :param part: One of "major", "minor", "patch", or "prerelease" :param prerelease_token: prefix string of prerelease, defaults to 'rc' - :return: + :return: new object with the appropriate part raised + :rtype: :class:`VersionInfo` """ validparts = { "major", @@ -463,7 +496,7 @@ return version.replace(prerelease=None, build=None) if part in ("major", "minor", "patch"): - return str(getattr(version, "bump_" + part)()) + return getattr(version, "bump_" + part)() if not version.prerelease: version = version.bump_patch() @@ -515,17 +548,16 @@ if ( isinstance(index, slice) - and (index.start is None or index.start < 0) - and (index.stop is None or index.stop < 0) + and (index.start is not None and index.start < 0) + or (index.stop is not None and index.stop < 0) ): raise IndexError("Version index cannot be negative") - # Could raise IndexError: - part = tuple(filter(None, self.to_tuple()[index])) + part = tuple(filter(lambda p: p is not None, self.to_tuple()[index])) if len(part) == 1: part = part[0] - if not part: + elif not part: raise IndexError("Version part undefined") return part @@ -611,9 +643,9 @@ Parse version string to a VersionInfo instance. :param version: version string - :return: a :class:`semver.VersionInfo` instance + :return: a :class:`VersionInfo` instance :raises: :class:`ValueError` - :rtype: :class:`semver.VersionInfo` + :rtype: :class:`VersionInfo` >>> semver.VersionInfo.parse('3.4.5-pre.2+build.4') VersionInfo(major=3, minor=4, patch=5, \ @@ -634,14 +666,14 @@ def replace(self, **parts): """ Replace one or more parts of a version and return a new - :class:`semver.VersionInfo` object, but leave self untouched + :class:`VersionInfo` object, but leave self untouched .. versionadded:: 2.9.0 Added :func:`VersionInfo.replace` :param dict parts: the parts to be updated. Valid keys are: ``major``, ``minor``, ``patch``, ``prerelease``, or ``build`` - :return: the new :class:`semver.VersionInfo` object with the changed + :return: the new :class:`VersionInfo` object with the changed parts :raises: :class:`TypeError`, if ``parts`` contains invalid keys """ @@ -780,6 +812,7 @@ return ver.match(match_expr) +@deprecated(replace="max", version="2.10.2") def max_ver(ver1, ver2): """ Returns the greater version of two versions strings. @@ -803,6 +836,7 @@ return ver2 +@deprecated(replace="min", version="2.10.2") def min_ver(ver1, ver2): """ Returns the smaller version of two versions strings. @@ -942,12 +976,12 @@ """ Remove any prerelease and build metadata from the version string. - .. versionadded:: 2.7.9 - Added :func:`finalize_version` - .. deprecated:: 2.10.0 Use :func:`semver.VersionInfo.finalize_version` instead. + .. versionadded:: 2.7.9 + Added :func:`finalize_version` + :param version: version string :return: the finalized version string :rtype: str @@ -964,12 +998,12 @@ """ Replace one or more parts of a version and return the new string. - .. versionadded:: 2.9.0 - Added :func:`replace` - .. deprecated:: 2.10.0 Use :func:`semver.VersionInfo.replace` instead. + .. versionadded:: 2.9.0 + Added :func:`replace` + :param str version: the version string to replace :param dict parts: the parts to be updated. Valid keys are: ``major``, ``minor``, ``patch``, ``prerelease``, or ``build`` diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/semver-2.10.0/test_semver.py new/semver-2.10.2/test_semver.py --- old/semver-2.10.0/test_semver.py 2020-05-05 17:29:22.000000000 +0200 +++ new/semver-2.10.2/test_semver.py 2020-06-15 17:33:05.000000000 +0200 @@ -25,6 +25,7 @@ parse_version_info, process, replace, + cmd_nextver, ) SEMVERFUNCS = [ @@ -659,6 +660,8 @@ v1 > 1 with pytest.raises(TypeError): 1 > v1 + with pytest.raises(TypeError): + v1.compare(1) def test_should_compare_prerelease_with_numbers_and_letters(): @@ -774,6 +777,8 @@ ("1.2.3", 0, 1), ("1.2.3", 1, 2), ("1.2.3", 2, 3), + # Special cases + ("1.0.2", 1, 0), ], ) def test_version_info_should_be_accessed_with_index(version, index, expected): @@ -801,6 +806,7 @@ ("1.2.3-rc.0+build.0", slice(0, 5, 2), (1, 3, "build.0")), ("1.2.3-rc.0+build.0", slice(None, 5, 2), (1, 3, "build.0")), ("1.2.3-rc.0+build.0", slice(5, 0, -2), ("build.0", 3)), + ("1.2.0-rc.0+build.0", slice(3), (1, 2, 0)), ], ) def test_version_info_should_be_accessed_with_slice_object( @@ -813,19 +819,37 @@ @pytest.mark.parametrize( "version, index", [ - ("1.2.3-rc.0+build.0", -1), - ("1.2.3-rc.0", -1), - ("1.2.3-rc.0", 4), - ("1.2.3", -1), ("1.2.3", 3), + ("1.2.3", slice(3, 4)), ("1.2.3", 4), - ("1.2.3", 10), - ("1.2.3", slice(-3)), + ("1.2.3", slice(4, 5)), + ("1.2.3", 5), + ("1.2.3", slice(5, 6)), + ("1.2.3-rc.0", 5), + ("1.2.3-rc.0", slice(5, 6)), + ("1.2.3-rc.0", 6), + ("1.2.3-rc.0", slice(6, 7)), ], ) def test_version_info_should_throw_index_error(version, index): version_info = VersionInfo.parse(version) - with pytest.raises(IndexError): + with pytest.raises(IndexError, match=r"Version part undefined"): + version_info[index] + + [email protected]( + "version, index", + [ + ("1.2.3", -1), + ("1.2.3", -2), + ("1.2.3", slice(-2, 2)), + ("1.2.3", slice(2, -2)), + ("1.2.3", slice(-2, -2)), + ], +) +def test_version_info_should_throw_index_error_when_negative_index(version, index): + version_info = VersionInfo.parse(version) + with pytest.raises(IndexError, match=r"Version index cannot be negative"): version_info[index] @@ -890,6 +914,22 @@ # check subcommand (cmd_check, Namespace(version="1.2.3"), does_not_raise(None)), (cmd_check, Namespace(version="1.2"), pytest.raises(ValueError)), + # nextver subcommand + ( + cmd_nextver, + Namespace(version="1.2.3", part="major"), + does_not_raise("2.0.0"), + ), + ( + cmd_nextver, + Namespace(version="1.2", part="major"), + pytest.raises(ValueError), + ), + ( + cmd_nextver, + Namespace(version="1.2.3", part="nope"), + pytest.raises(ValueError), + ), ], ) def test_should_process_parsed_cli_arguments(func, args, expectation): @@ -996,6 +1036,8 @@ (parse, ("1.2.3",), {}), (parse_version_info, ("1.2.3",), {}), (replace, ("1.2.3",), dict(major=2, patch=10)), + (max_ver, ("1.2.3", "1.2.4"), {}), + (min_ver, ("1.2.3", "1.2.4"), {}), ], ) def test_should_raise_deprecation_warnings(func, args, kwargs): @@ -1050,4 +1092,39 @@ ) def test_next_version_with_versioninfo(version, part, expected): ver = VersionInfo.parse(version) - assert str(ver.next_version(part)) == expected + next_version = ver.next_version(part) + assert isinstance(next_version, VersionInfo) + assert str(next_version) == expected + + [email protected]( + "version, expected", + [ + ( + VersionInfo(major=1, minor=2, patch=3, prerelease=None, build=None), + "VersionInfo(major=1, minor=2, patch=3, prerelease=None, build=None)", + ), + ( + VersionInfo(major=1, minor=2, patch=3, prerelease="r.1", build=None), + "VersionInfo(major=1, minor=2, patch=3, prerelease='r.1', build=None)", + ), + ( + VersionInfo(major=1, minor=2, patch=3, prerelease="dev.1", build=None), + "VersionInfo(major=1, minor=2, patch=3, prerelease='dev.1', build=None)", + ), + ( + VersionInfo(major=1, minor=2, patch=3, prerelease="dev.1", build="b.1"), + "VersionInfo(major=1, minor=2, patch=3, prerelease='dev.1', build='b.1')", + ), + ( + VersionInfo(major=1, minor=2, patch=3, prerelease="r.1", build="b.1"), + "VersionInfo(major=1, minor=2, patch=3, prerelease='r.1', build='b.1')", + ), + ( + VersionInfo(major=1, minor=2, patch=3, prerelease="r.1", build="build.1"), + "VersionInfo(major=1, minor=2, patch=3, prerelease='r.1', build='build.1')", + ), + ], +) +def test_repr(version, expected): + assert repr(version) == expected
