diff options
author | Raphaël Barrois <raphael.barrois@polytechnique.org> | 2012-05-20 21:49:00 +0200 |
---|---|---|
committer | Raphaël Barrois <raphael.barrois@polytechnique.org> | 2012-05-20 21:49:00 +0200 |
commit | e0ef7b8fe2f8f5f9945b008091c25de51f61f8aa (patch) | |
tree | 4081c85b061e87029eaa83439fe1766feb7c1f35 /tests/test_base.py | |
parent | f075232bdf1af843d875350c1213e021da19f799 (diff) | |
download | semantic-version-e0ef7b8fe2f8f5f9945b008091c25de51f61f8aa.tar.gz |
Update rules and code to follow readable specifications.
Signed-off-by: Raphaël Barrois <raphael.barrois@polytechnique.org>
Diffstat (limited to 'tests/test_base.py')
-rwxr-xr-x | tests/test_base.py | 102 |
1 files changed, 51 insertions, 51 deletions
diff --git a/tests/test_base.py b/tests/test_base.py index 894c4c3..49133c1 100755 --- a/tests/test_base.py +++ b/tests/test_base.py @@ -101,22 +101,22 @@ class VersionTestCase(unittest.TestCase): self.assertNotEqual(text, base.Version(text)) partial_versions = { - '1.0': (1, 0, None, None, None), - '1': (1, None, None, None, None), '1.0.0-alpha': (1, 0, 0, ('alpha',), None), '1.0.0-alpha.1': (1, 0, 0, ('alpha', '1'), None), '1.0.0-beta.2': (1, 0, 0, ('beta', '2'), None), '1.0.0-beta.11': (1, 0, 0, ('beta', '11'), None), '1.0.0-rc.1': (1, 0, 0, ('rc', '1'), None), - '1.0.0-rc.1+build.1': (1, 0, 0, ('rc', '1'), ('build', '1')), '1.0.0': (1, 0, 0, None, None), + '1.1.1': (1, 1, 1, None, None), + '1.1.2': (1, 1, 2, None, None), + '1.1.3-rc4.5': (1, 1, 3, ('rc4', '5'), None), + '1.0.0-': (1, 0, 0, (), None), + '1.0.0+': (1, 0, 0, (), ()), + '1.0.0-rc.1+build.1': (1, 0, 0, ('rc', '1'), ('build', '1')), '1.0.0+0.3.7': (1, 0, 0, (), ('0', '3', '7')), '1.3.7+build': (1, 3, 7, (), ('build',)), '1.3.7+build.2.b8f12d7': (1, 3, 7, (), ('build', '2', 'b8f12d7')), '1.3.7+build.11.e0f985a': (1, 3, 7, (), ('build', '11', 'e0f985a')), - '1.1.1': (1, 1, 1, None, None), - '1.1.2': (1, 1, 2, None, None), - '1.1.3-rc4.5': (1, 1, 3, ('rc4', '5'), None), '1.1.3-rc42.3-14-15.24+build.2012-04-13.223': (1, 1, 3, ('rc42', '3-14-15', '24'), ('build', '2012-04-13', '223')), '1.1.3+build.2012-04-13.HUY.alpha-12.1': @@ -163,18 +163,17 @@ class VersionTestCase(unittest.TestCase): class SpecTestCase(unittest.TestCase): components = { - '~=0.1': (base.Spec.KIND_EQ_LOOSE, 0, 1, None, None, None), - '~=0.1.2-rc3': (base.Spec.KIND_EQ_LOOSE, 0, 1, 2, ('rc3',), None), - '~=0.1.2+build3.14': (base.Spec.KIND_EQ_LOOSE, 0, 1, 2, (), ('build3', '14')), - '<=0.1.1': (base.Spec.KIND_LTE, 0, 1, 1, (), ()), - '<0.1.1': (base.Spec.KIND_LT, 0, 1, 1, (), ()), - '<~0.1.1': (base.Spec.KIND_LTE_LOOSE, 0, 1, 1, None, None), - '<~0.1': (base.Spec.KIND_LTE_LOOSE, 0, 1, None, None, None), - '>=0.2.3-rc2': (base.Spec.KIND_GTE, 0, 2, 3, ('rc2',), ()), - '>0.2.3-rc2': (base.Spec.KIND_GT, 0, 2, 3, ('rc2',), ()), - '>~2': (base.Spec.KIND_GTE_LOOSE, 2, None, None, None, None), - '!=0.1.1': (base.Spec.KIND_NEQ, 0, 1, 1, (), ()), - '!~0.3': (base.Spec.KIND_NEQ_LOOSE, 0, 3, None, None, None), + '==0.1.0': (base.Spec.KIND_EQUAL, 0, 1, 0, None, None), + '==0.1.2-rc3': (base.Spec.KIND_EQUAL, 0, 1, 2, ('rc3',), None), + '==0.1.2+build3.14': (base.Spec.KIND_EQUAL, 0, 1, 2, (), ('build3', '14')), + '<=0.1.1+': (base.Spec.KIND_LTE, 0, 1, 1, (), ()), + '<0.1.1': (base.Spec.KIND_LT, 0, 1, 1, None, None), + '<=0.1.1': (base.Spec.KIND_LTE, 0, 1, 1, None, None), + '>=0.2.3-rc2': (base.Spec.KIND_GTE, 0, 2, 3, ('rc2',), None), + '>0.2.3-rc2+': (base.Spec.KIND_GT, 0, 2, 3, ('rc2',), ()), + '>=2.0.0': (base.Spec.KIND_GTE, 2, 0, 0, None, None), + '!=0.1.1+': (base.Spec.KIND_NEQ, 0, 1, 1, (), ()), + '!=0.3.0': (base.Spec.KIND_NEQ, 0, 3, 0, None, None), } def test_components(self): @@ -182,9 +181,6 @@ class SpecTestCase(unittest.TestCase): kind, major, minor, patch, prerelease, build = components spec = base.Spec(spec_text) - self.assertNotEqual(spec, spec_text) - self.assertEqual(spec_text, str(spec)) - self.assertEqual(kind, spec.kind) self.assertEqual(major, spec.spec.major) self.assertEqual(minor, spec.spec.minor) @@ -192,54 +188,57 @@ class SpecTestCase(unittest.TestCase): self.assertEqual(prerelease, spec.spec.prerelease) self.assertEqual(build, spec.spec.build) + self.assertNotEqual(spec, spec_text) + self.assertEqual(spec_text, str(spec)) + matches = { - '~=0.1': ( - ['0.1.0', '0.1.99', '0.1.0-rc1', '0.1.4-rc1+build2'], - ['0.0.1', '0.2.0'], + '==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.2-rc3': ( + '==0.1.2-rc3': ( ['0.1.2-rc3+build1', '0.1.2-rc3+build4.5'], ['0.1.2-rc4', '0.1.2', '0.1.3'], ), - '~=0.1.2+build3.14': ( + '==0.1.2+build3.14': ( ['0.1.2+build3.14'], ['0.1.2-rc+build3.14', '0.1.2+build3.15'], ), '<=0.1.1': ( - ['0.0.0', '0.1.1-alpha1', '0.1.1'], - ['0.1.1+build2', '0.1.2'], + ['0.0.0', '0.1.1-alpha1', '0.1.1', '0.1.1+build2'], + ['0.1.2'], ), '<0.1.1': ( - ['0.1.0', '0.1.1-zzz+999', '0.0.0'], - ['0.1.1', '1.2.0', '0.1.1+build3'], + ['0.1.0', '0.0.0'], + ['0.1.1', '0.1.1-zzz+999', '1.2.0', '0.1.1+build3'], ), - '<~0.1.1': ( + '<=0.1.1': ( ['0.1.1+build4', '0.1.1-alpha', '0.1.0'], ['0.2.3', '1.1.1', '0.1.2'], ), - '<~0.1': ( - ['0.1.0', '0.1.1+4', '0.1.99', '0.1.0-alpha', '0.0.1'], - ['0.2.0', '1.0.0'], + '<0.1.1-': ( + ['0.1.0', '0.1.1-alpha', '0.1.1-alpha+4'], + ['0.2.0', '1.0.0', '0.1.1', '0.1.1+build1'], ), '>=0.2.3-rc2': ( ['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-rc2': ( + '>0.2.3-rc2+': ( ['0.2.3-rc3', '0.2.3', '0.2.3-rc2+1'], - ['0.2.3-rc1', '0.2.2'], + ['0.2.3-rc1', '0.2.2', '0.2.3-rc2'], ), - '>~2': ( - ['2.1.1', '2.0.0-alpha1', '3.1.4'], - ['1.9.9', '1.9.9999'], + '>2.0.0+': ( + ['2.1.1', '2.0.0+b1', '3.1.4'], + ['1.9.9', '1.9.9999', '2.0.0', '2.0.0-rc4'], ), '!=0.1.1': ( - ['0.1.1-alpha', '0.1.2', '0.1.0', '1.4.2'], - ['0.1.1'], + ['0.1.2', '0.1.0', '1.4.2'], + ['0.1.1', '0.1.1-alpha', '0.1.1+b1'], ), - '!~0.3': ( - ['0.4.0', '1.3.0'], - ['0.3.0', '0.3.99', '0.3.0-alpha', '0.3.999999+4'], + '!=0.3.4-': ( + ['0.4.0', '1.3.0', '0.3.4-alpha', '0.3.4-alpha+b1'], + ['0.3.4', '0.3.4+b1'], ), } @@ -279,7 +278,7 @@ class SpecTestCase(unittest.TestCase): class SpecListTestCase(unittest.TestCase): examples = { '>=0.1.1,<0.1.2': ['>=0.1.1', '<0.1.2'], - '>~0.1,!=0.1.3-rc1,<0.1.3': ['>~0.1', '!=0.1.3-rc1', '<0.1.3'], + '>=0.1.0,!=0.1.3-rc1,<0.1.3': ['>=0.1.0', '!=0.1.3-rc1', '<0.1.3'], } def test_parsing(self): @@ -295,7 +294,7 @@ class SpecListTestCase(unittest.TestCase): split_examples = { ('>=0.1.1', '<0.1.2', '!=0.1.1+build1'): ['>=0.1.1', '<0.1.2', '!=0.1.1+build1'], - ('>~0.1', '!=0.1.3-rc1,<0.1.3'): ['>~0.1', '!=0.1.3-rc1', '<0.1.3'], + ('>=0.1.0', '!=0.1.3-rc1,<0.1.3'): ['>=0.1.0', '!=0.1.3-rc1', '<0.1.3'], } def test_parsing_split(self): @@ -311,12 +310,13 @@ class SpecListTestCase(unittest.TestCase): matches = { '>=0.1.1,<0.1.2': ( - ['0.1.1', '0.1.2-alpha', '0.1.1+4'], - ['0.1.1-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'], ), - '>~0.1,!=0.1.3-rc1,<0.1.3': ( - ['0.1.1', '0.1.3-rc1+4', '0.1.3-alpha'], - ['0.0.1', '0.1.3', '0.2.2', '0.1.3-rc1'], + '>=0.1.0+,!=0.1.3-rc1,<0.1.4': ( + ['0.1.1', '0.1.0+b4', '0.1.2', '0.1.3-rc2'], + ['0.0.1', '0.1.4', '0.1.4-alpha', '0.1.3-rc1+4', + '0.1.0-alpha', '0.2.2', '0.1.4-rc1'], ), } |