summaryrefslogtreecommitdiff
path: root/tests/test_match.py
diff options
context:
space:
mode:
authorRaphaël Barrois <raphael.barrois@polytechnique.org>2015-09-15 23:18:13 +0200
committerRaphaël Barrois <raphael.barrois@polytechnique.org>2015-09-15 23:40:59 +0200
commit2ed3d39c291080c61edd9139370939e1fdc3209a (patch)
tree22a90dfae0e0fc9fd7949ca18e7e47daa8f8aabb /tests/test_match.py
parent4aac5768db2fc158fa87900b54210ecba4dfe6d5 (diff)
downloadsemantic-version-2ed3d39c291080c61edd9139370939e1fdc3209a.tar.gz
Forbid build metadata ordering (See #18)
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')``
Diffstat (limited to 'tests/test_match.py')
-rwxr-xr-xtests/test_match.py32
1 files changed, 17 insertions, 15 deletions
diff --git a/tests/test_match.py b/tests/test_match.py
index 155a612..6926e0a 100755
--- a/tests/test_match.py
+++ b/tests/test_match.py
@@ -15,6 +15,7 @@ class MatchTestCase(unittest.TestCase):
'<=0.1.4a',
'>0.1.1.1',
'~0.1.2-rc23,1',
+ '<0.1.2-rc1.3-14.15+build.2012-01-01.11h34',
]
valid_specs = [
@@ -25,7 +26,7 @@ class MatchTestCase(unittest.TestCase):
'>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-rc1.3-14.15+build.2012-01-01.11h34',
]
matches = {
@@ -53,11 +54,19 @@ class MatchTestCase(unittest.TestCase):
'0.1.2',
'0.1.2+build4',
],
- '<0.1.2+': [
+ '!=0.1.2+': [
+ '0.1.2+1',
+ '0.1.2-rc1',
+ ],
+ '!=0.1.2-': [
'0.1.1',
'0.1.2-rc1',
- '0.1.2-rc1.3.4',
- '0.1.2-rc1+build4.5',
+ ],
+ '!=0.1.2+345': [
+ '0.1.1',
+ '0.1.2-rc1+345',
+ '0.1.2+346',
+ '0.2.3+345',
],
'>=0.1.1': [
'0.1.1',
@@ -72,12 +81,6 @@ class MatchTestCase(unittest.TestCase):
'0.2.0',
'1.0.0',
],
- '>0.1.1+': [
- '0.1.1+b2',
- '0.1.2-rc1',
- '1.1.1',
- '2.0.4',
- ],
'<0.1.1-': [
'0.1.1-alpha',
'0.1.1-rc4',
@@ -87,7 +90,8 @@ class MatchTestCase(unittest.TestCase):
def test_invalid(self):
for invalid in self.invalid_specs:
- self.assertRaises(ValueError, semantic_version.Spec, invalid)
+ with self.assertRaises(ValueError, msg="Spec(%r) should be invalid" % invalid):
+ semantic_version.Spec(invalid)
def test_simple(self):
for valid in self.valid_specs:
@@ -122,11 +126,9 @@ class MatchTestCase(unittest.TestCase):
self.assertFalse(version in strict_spec, "%r should not be in %r" % (version, strict_spec))
def test_build_check(self):
- strict_spec = semantic_version.Spec('<=0.1.1-rc1+')
- lax_spec = semantic_version.Spec('<=0.1.1-rc1')
+ spec = semantic_version.Spec('<=0.1.1-rc1')
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 strict_spec, "%r should not be in %r" % (version, strict_spec))
+ self.assertTrue(version in spec, "%r should be in %r" % (version, spec))
if __name__ == '__main__': # pragma: no cover