diff options
author | Raphaël Barrois <raphael.barrois@polytechnique.org> | 2019-08-23 19:26:24 +0200 |
---|---|---|
committer | Raphaël Barrois <raphael.barrois@polytechnique.org> | 2019-08-24 15:13:09 +0200 |
commit | c24f4e2157438be40b44e6ba02d90c6bfa934454 (patch) | |
tree | 66ecf2747c6a605688c0a934d94bab539085c11e /tests | |
parent | 13902f1812697bac01ea1172663a6eedd20ac9d5 (diff) | |
download | semantic-version-c24f4e2157438be40b44e6ba02d90c6bfa934454.tar.gz |
Fix inconsistent matching behaviour.
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.
Diffstat (limited to 'tests')
-rwxr-xr-x | tests/test_base.py | 48 | ||||
-rwxr-xr-x | tests/test_match.py | 13 |
2 files changed, 28 insertions, 33 deletions
diff --git a/tests/test_base.py b/tests/test_base.py index 76d120b..d5794b3 100755 --- a/tests/test_base.py +++ b/tests/test_base.py @@ -83,7 +83,7 @@ class TopLevelTestCase(unittest.TestCase): matches = ( ('>=0.1.1', '0.1.2'), ('>=0.1.1', '0.1.1'), - ('>=0.1.1', '0.1.1-alpha'), + ('>=0.1.1', '0.1.2-alpha'), ('>=0.1.1,!=0.2.0', '0.2.1'), ) @@ -463,16 +463,16 @@ class SpecItemTestCase(unittest.TestCase): matches = { '==0.1.0': ( - ['0.1.0', '0.1.0-rc1', '0.1.0+build1', '0.1.0-rc1+build2'], - ['0.0.1', '0.2.0', '0.1.1'], + ['0.1.0', '0.1.0+build1'], + ['0.0.1', '0.1.0-rc1', '0.2.0', '0.1.1', '0.1.0-rc1+build2'], ), '=0.1.0': ( - ['0.1.0', '0.1.0-rc1', '0.1.0+build1', '0.1.0-rc1+build2'], - ['0.0.1', '0.2.0', '0.1.1'], + ['0.1.0', '0.1.0+build1'], + ['0.0.1', '0.1.0-rc1', '0.2.0', '0.1.1', '0.1.0-rc1+build2'], ), '0.1.0': ( - ['0.1.0', '0.1.0-rc1', '0.1.0+build1', '0.1.0-rc1+build2'], - ['0.0.1', '0.2.0', '0.1.1'], + ['0.1.0', '0.1.0+build1'], + ['0.0.1', '0.1.0-rc1', '0.2.0', '0.1.1', '0.1.0-rc1+build2'], ), '==0.1.2-rc3': ( ['0.1.2-rc3+build1', '0.1.2-rc3+build4.5'], @@ -502,6 +502,10 @@ class SpecItemTestCase(unittest.TestCase): ['0.2.3-rc3', '0.2.3', '0.2.3+1', '0.2.3-rc2', '0.2.3-rc2+1'], ['0.2.3-rc1', '0.2.2'], ), + '>=0.2.3': ( + ['0.2.3', '0.2.3+1'], + ['0.2.3-rc3', '0.2.3-rc2', '0.2.3-rc2+1', '0.2.3-rc1', '0.2.2'], + ), '==0.2.3+': ( ['0.2.3'], ['0.2.3+rc1', '0.2.4', '0.2.3-rc2'], @@ -523,32 +527,32 @@ class SpecItemTestCase(unittest.TestCase): ['0.3.4', '0.3.4+b1'], ), '~1.1.2': ( - ['1.1.3', '1.1.2-alpha', '1.1.2-alpha+b1'], - ['1.1.1', '1.2.1', '2.1.0'], + ['1.1.3', '1.1.2+b1'], + ['1.1.1', '1.1.2-alpha', '1.1.2-alpha+b1', '1.2.1', '2.1.0'], ), '^1.1.2': ( - ['1.1.3', '1.2.1', '1.1.2-alpha', '1.1.2-alpha+b1'], - ['1.1.1', '2.1.0'], + ['1.1.3', '1.1.2+b1', '1.2.1'], + ['1.1.1', '1.1.2-alpha', '1.1.2-alpha+b1', '2.1.0'], ), '^0.1.2': ( - ['0.1.2', '0.1.2-alpha', '0.1.3'], - ['0.2.0', '1.1.2', '0.1.1'], + ['0.1.2', '0.1.2+b1', '0.1.3'], + ['0.1.2-alpha', '0.2.0', '1.1.2', '0.1.1'], ), '^0.0.2': ( - ['0.0.2', '0.0.2-alpha', '0.0.2+abb'], - ['0.1.0', '0.0.3', '1.0.0'], + ['0.0.2', '0.0.2+abb'], + ['0.0.2-alpha', '0.1.0', '0.0.3', '1.0.0'], ), '~=1.4.5': ( ['1.4.5', '1.4.10-alpha', '1.4.10'], - ['1.3.6', '1.4.4', '1.5.0'], + ['1.3.6', '1.4.4', '1.4.5-alpha', '1.5.0'], ), '~=1.4.0': ( ['1.4.0', '1.4.10-alpha', '1.4.10'], - ['1.3.6', '1.3.9', '1.5.0'], + ['1.3.6', '1.3.9', '1.4.0-alpha', '1.5.0'], ), '~=1.4': ( ['1.4.0', '1.6.10-alpha', '1.6.10'], - ['1.3.0', '2.0.0'], + ['1.3.0', '1.4.0-alpha', '2.0.0'], ), } @@ -646,12 +650,12 @@ class SpecTestCase(unittest.TestCase): self.assertIn(str(base.SpecItem(spec_text)), repr(spec_list)) matches = { - # At least 0.1.1 including pre-releases, less than 0.1.2 excluding pre-releases + # At least 0.1.1 excluding pre-releases, less than 0.1.2 excluding pre-releases '>=0.1.1,<0.1.2': ( - ['0.1.1', '0.1.1+4', '0.1.1-alpha'], - ['0.1.2-alpha', '0.1.2', '1.3.4'], + ['0.1.1', '0.1.1+4'], + ['0.1.1-alpha', '0.1.2-alpha', '0.1.2', '1.3.4'], ), - # At least 0.1.0 without pre-releases, less than 0.1.4 excluding pre-releases, + # At least 0.1.0 with pre-releases, less than 0.1.4 excluding pre-releases, # neither 0.1.3-rc1 nor any build of that version, # not 0.1.0+b3 precisely '>=0.1.0-,!=0.1.3-rc1,!=0.1.0+b3,<0.1.4': ( diff --git a/tests/test_match.py b/tests/test_match.py index 16d7e5a..4bf7162 100755 --- a/tests/test_match.py +++ b/tests/test_match.py @@ -47,22 +47,13 @@ class MatchTestCase(unittest.TestCase): '1.0.0', ], '==0.1.2': [ - '0.1.2-rc1', - '0.1.2-rc1.3.4', '0.1.2+build42-12.2012-01-01.12h23', - '0.1.2-rc1.3-14.15+build.2012-01-01.11h34', ], '=0.1.2': [ - '0.1.2-rc1', - '0.1.2-rc1.3.4', '0.1.2+build42-12.2012-01-01.12h23', - '0.1.2-rc1.3-14.15+build.2012-01-01.11h34', ], '0.1.2': [ - '0.1.2-rc1', - '0.1.2-rc1.3.4', '0.1.2+build42-12.2012-01-01.12h23', - '0.1.2-rc1.3-14.15+build.2012-01-01.11h34', ], '<=0.1.2': [ '0.1.1', @@ -146,9 +137,9 @@ class MatchTestCase(unittest.TestCase): spec = semantic_version.Spec(spec_text) self.assertNotEqual(spec, spec_text) version = semantic_version.Version(version_text) + self.assertIn(version, spec) self.assertTrue(spec.match(version), "%r does not match %r" % (version, spec)) self.assertTrue(semantic_version.match(spec_text, version_text)) - self.assertTrue(version in spec, "%r not in %r" % (version, spec)) def test_contains(self): spec = semantic_version.Spec('<=0.1.1') @@ -164,7 +155,7 @@ class MatchTestCase(unittest.TestCase): strict_spec = semantic_version.Spec('>=0.1.1-') lax_spec = semantic_version.Spec('>=0.1.1') version = semantic_version.Version('0.1.1-rc1+4.2') - self.assertTrue(version in lax_spec, "%r should be in %r" % (version, lax_spec)) + self.assertFalse(version in lax_spec, "%r should not be in %r" % (version, lax_spec)) self.assertFalse(version in strict_spec, "%r should not be in %r" % (version, strict_spec)) def test_build_check(self): |