summaryrefslogtreecommitdiff
path: root/tests
Commit message (Collapse)AuthorAgeFilesLines
* Simplify subclassing VersionHEADsubclasseablemasterRaphaël Barrois2023-02-281-0/+9
| | | | Fixes: #112
* Test and fix Version.truncate()Raphaël Barrois2023-02-281-0/+10
| | | | | | | Calling `Version.truncate("build")` should return a fresh instance, as caught in #141 Closes: #141, #142
* Guarantee a stable ordering with build metadataRaphaël Barrois2022-05-261-0/+14
| | | | | | | | | | | | | Sorting any permutation of Version objects should always yield the same result, even if those hold some build metadata. To that end, the "precedence_key" is now used exclusively for sorting; direct comparisons between Version objects still ignores the "build" metadata, using a different precedence key. For performance improvements, both precedence keys are cached. Closes: #132
* Linting.Raphaël Barrois2020-07-074-0/+10
| | | | Add missing blank lines.
* Add tests for Django's get_or_create.Raphaël Barrois2020-07-071-0/+14
| | | | Related to issue #97.
* Fix wildcard matching for SimpleSpec.Raphaël Barrois2020-04-291-0/+10
| | | | | | Including docs and tests. Closes #98.
* Properly coerce versions with leading zeroes.Raphaël Barrois2019-12-211-1/+1
| | | | | | | A leading zero is forbidden in the SemVer spec, but could be valid under other schemes; when coercing, it can easily be removed. Closes #89, thanks to Andrew Ni for the report.
* Fix NpmSpec prerelease-handling.Raphaël Barrois2019-11-211-0/+4
| | | | | | | | | | | | | Thanks to Nathan Walters for spotting this. Npm ranges with a `<X.Y.Z-P` component were not properly expanded: they were converted to: <X.Y.0 || (>=X.Y.0 && <X.Y.Z-P && no-prerelease) The correct expansion is: <X.Y.0 || (>=X.Y.0-* && <X.Y.Z-P) Closes #86.
* Fix Spec.specs for single-term ranges.maint/2.xRaphaël Barrois2019-09-061-3/+4
| | | | | | | This (deprecated) property failed when used on a `Spec` item based on a single-term range (e.g. `==0.1.2` `<2.0.0`). Closes #82.
* Restore Python2 support.rbarrois/restore-py2Raphaël Barrois2019-08-294-0/+66
|
* Fix NPM-style caret matching.Raphaël Barrois2019-08-281-0/+12
|
* Add `Version.precedence_key`.Raphaël Barrois2019-08-262-53/+2
| | | | | | | | | | | | | | | | | | | This will be used in `sort(..., key=lambda v: v.precedence_key)`. Remove previous comparison/ordering implementation. The current implementation relies on a 4-tuple: - major, minor, patch (as integers) - natural order matches precedence rules - a tuple of identifiers for the prerelease component. The identifiers for the prerelease components are based on: - A `NumericIdentifier` class, that compares number using their natural order, and always compares lower than non-numeric identifiers - A `AlphaIdentifier` class for non-numeric identifiers; it compares versions using ASCII ordering. - A `MaxIdentifier` class, that compares higher to any other identifier; used to ensure that a non-prerelease version is greater than any of its prereleases.
* Add support for NPM-style version ranges.Raphaël Barrois2019-08-263-3/+105
| | | | | | | | The code follows closely the specification available at https://docs.npmjs.com/misc/semver.html. Despite similarities, the matching logic is fully separate from the `native` code, since both might evolve at their own scales.
* Refactor spec/version matching.Raphaël Barrois2019-08-261-20/+23
| | | | | | | | | | | | | | | | | | | | | | | Instead of choosing the comparison on each `.match()` call, the expression is converted to a combination of `Range()` expressions (simple comparison to a semver-compliant `Version`). `Range()` objects can be combined with `And` and `Or` through the `AnyOf` and `AllOf` clauses (sticking to Python's naming scheme). Some specific flags have been provided to those range, allowing users to subtly alter the matching behaviour - thus accomodating different versioning schemes: - `<0.1.2` won't match `0.1.2-rc1`, unless the prerelease_policy flag is set to either `always` or `same-patch` - `<0.1.2` will match `0.1.1-rc1`, unless the `prerelease_policy` flag is set to `same-patch` - `==0.1.2` will always match `0.1.2+build44`, unless the `build_policy` is set to `strict`. The `Spec` item has been updated, alongside `SpecItem`. Those objects keep the original expression as attributes, but don't use them for comparisons.
* Fix inconsistent matching behaviour.Raphaël Barrois2019-08-242-33/+28
| | | | | | | | According to the stated goal of "intuitive" behaviour, we want: ``Version('0.1.1-a1') not in Spec('<0.1.1')``. Tests, code and docs have been fixed.
* Lint test code.Raphaël Barrois2019-08-248-35/+35
|
* Use unittest.subTest in tests.Raphaël Barrois2019-08-243-124/+168
| | | | This provides more helpful error messages when a test fails.
* Drop support for Python<3.4.Raphaël Barrois2019-08-246-40/+13
|
* Allow Version(major=1, ...).Raphaël Barrois2019-08-241-0/+21
| | | | | | Eases the creation of version objects from existing versions. We still validate the type and structure of each component.
* Remove hacks for old Django under Pypy.Raphaël Barrois2018-06-181-8/+0
|
* Adapt code to Django>=1.11.Raphaël Barrois2018-06-181-8/+1
| | | | Drop compatibility layer for Django<1.11.
* Fix deconstruct() tests under Pypy.Raphaël Barrois2016-09-011-8/+18
| | | | | Pypy seems to deconstruct fields differently from Django, thus bringing in variations in the actual deconstruct() output.
* django: Replace south with django.db.migrationsRaphaël Barrois2016-09-012-103/+103
| | | | Update tests accordingly.
* Add support for Django 1.10Raphaël Barrois2016-09-011-31/+58
| | | | | | | | | | | | | | Stop coercing fields magically: >>> a = SomeModel() >>> a.version = '0.1.0' >>> a.version '0.1.0' >>> a.full_clean() >>> a.version Version('0.1.0') Closes #43, #45
* Fix a bug with compatible release clauses and patch versionsMartin Ek2016-03-071-0/+4
| | | | | Previously, if the patch version was 0 (i.e. as in ~=2.2.0), this would cause the range to be interpreted as ~=2.2.
* Add support for compatible release ranges, fixes #37Martin Ek2016-02-252-0/+19
|
* Fix handling pre-1.0.0 caret versions (Closes #35)Raphaël Barrois2016-02-212-1/+9
| | | | Thanks to @autopulated for pointing the issue!
* Cleanup and document fixes from #31.Raphaël Barrois2016-02-122-5/+23
| | | | The PR was broken through fixed in ``next_minor()`` / ``next_major()``.
* Merge branch 'tilde-caret' of ↵Raphaël Barrois2016-02-121-1/+28
|\ | | | | | | https://github.com/skwashd/python-semanticversion into skwashd-tilde-caret
| * Fix broken testDave Hall2015-11-301-1/+1
| |
| * Support for alternative equals specsDave Hall2015-11-291-0/+14
| | | | | | | | | | Composer assumes equals if no operator is used npm uses a single equals operator
| * Add support for npm/composer caret and tilde condition extensionsDave Hall2015-10-151-0/+13
| |
* | Remove Copyright years (Closes #28)Raphaël Barrois2016-02-128-8/+8
| | | | | | | | It seems that stating the copyright years is useless after all :)
* | Merge branch 'bump-version-2' of ↵Raphaël Barrois2016-02-121-2/+126
|\ \ | | | | | | | | | https://github.com/MinchinWeb/python-semanticversion into MinchinWeb-bump-version-2
| * | add tests for bumping prerelease versionsMinchinWeb2015-09-151-2/+126
| | |
* | | Fix for failing test_django testsHugo Rodger-Brown2015-11-251-15/+9
| | | | | | | | | | | | | | | | | | I've added a save_and_refresh function to allow objects to be saved and then updated from the database, replicating the refresh_from_db method that exists in Django 1.8, and wrapping in the save method.
* | | Fix issue #33 - null VersionField breaks ORMHugo Rodger-Brown2015-11-241-0/+45
| |/ |/| | | | | | | | | | | | | | | | | | | | | | | | | I've updated the `BaseSemVerField` method `get_prep_value` so that it will return None when the field value is None, rather than the string representation 'None'. Previously this would break the ORM, which would save the string 'None' into the database, and then attempt to parse that as a version number. This change means that the default empty value for both VersionField and SpecField is None. Both derive from CharField, which uses an empty string as its default empty value, however it seems more logical in the case of these objects that no object is null, and not an empty string. Includes tests.
* | Forbid build metadata ordering (See #18)Raphaël Barrois2015-09-154-39/+79
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | SemVer 2.0.0 states that "Build metadata SHOULD be ignored when determining version precedence". This means that, when comparing ``0.1.0+1`` to ``0.1.0+bcd``:: >>> Version('0.1.0+1') == Version('0.1.0+bcd') False >>> Version('0.1.0+1') != Version('0.1.0+bcd') True >>> Version('0.1.0+1') < Version('0.1.0+bcd') False >>> Version('0.1.0+1') > Version('0.1.0+bcd') False >>> Version('0.1.0+1') <= Version('0.1.0+bcd') False >>> Version('0.1.0+1') >= Version('0.1.0+bcd') False >>> compare(Version('0.1.0+1'), Version('0.1.0+bcd')) NotImplemented This change also has the following effects: - When including build metadata in a ``Spec``, the only valid options are ``Spec('==0.1.0+sth')`` and ``Spec('!=0.1.0+sth')`` - The meaning of ``Spec('==0.1.0+')`` is now "Only version 0.1.0 without build metadata" - ``Spec('==0.1.0')`` now matches ``Version('0.1.0+anything')``
* Minor fixes to tests.Raphaël Barrois2015-07-022-5/+5
|
* fixed tests to work with django 1.7 and 1.8Michael Hrivnak2015-07-022-17/+32
| | | | | | Added several django versions to the travis-ci build fixes #22
* Adds a new bump version func to the API.Rick Eyre2015-04-011-0/+28
|
* Accept '*' as a Spec (Closes #8).Raphaël Barrois2014-03-161-0/+12
| | | | Spec('*') will match all valid Version objects.
* moved django test app settings to the django test app moduleMichael Hrivnak2014-03-162-12/+24
| | | | | | | | | ... to guarantee the settings get executed before any code in that app. Since python's unittest.TestLoader does not guarantee in what order it will import modules while hunting for test cases, the unit tests could fail to even load if tests.django_test_app.models was loaded before tests.test_django. This failure was seen on ARM machines, which happened to traverse the module tree in an inconvenient order.
* Update copyrightRaphaël Barrois2014-03-087-7/+7
|
* Upgrade to semver-2.0.0 (Closes #3)Raphaël Barrois2014-02-132-2/+165
|
* tests: Fix test running when Django isn't available.Raphaël Barrois2013-12-231-12/+19
|
* Add Python3 support.Raphaël Barrois2013-03-214-7/+42
|
* Fix license string.Raphaël Barrois2013-03-214-1/+4
|
* Add semantic_version.validate (Closes #2).Raphaël Barrois2013-03-211-0/+40
| | | | | | Simple way of testing whether a string is a 'valid' SemVer version. Signed-off-by: Raphaël Barrois <raphael.barrois@polytechnique.org>
* Add Version.coerce.Raphaël Barrois2013-03-203-0/+49
| | | | Some people don't use semver yet...