diff options
author | Raphaël Barrois <raphael.barrois@polytechnique.org> | 2013-03-20 02:02:02 +0100 |
---|---|---|
committer | Raphaël Barrois <raphael.barrois@polytechnique.org> | 2013-03-20 02:02:02 +0100 |
commit | f84d754af1ae86aaa9a891445d6ae5be36668a85 (patch) | |
tree | d56cb28242391a2d05b3601efd03202298e00cb3 /tests | |
parent | 658ac42850e3b4c4923365287d55ec17be4806de (diff) | |
download | semantic-version-f84d754af1ae86aaa9a891445d6ae5be36668a85.tar.gz |
Fix handling of partial versions (Closes #1).
Diffstat (limited to 'tests')
-rwxr-xr-x | tests/test_base.py | 1 | ||||
-rw-r--r-- | tests/test_django.py | 7 | ||||
-rwxr-xr-x | tests/test_match.py | 16 |
3 files changed, 21 insertions, 3 deletions
diff --git a/tests/test_base.py b/tests/test_base.py index 52d2e84..90dbe96 100755 --- a/tests/test_base.py +++ b/tests/test_base.py @@ -197,6 +197,7 @@ class SpecItemTestCase(unittest.TestCase): '<=0.1.1+': (base.SpecItem.KIND_LTE, 0, 1, 1, (), ()), '<0.1.1': (base.SpecItem.KIND_LT, 0, 1, 1, None, None), '<=0.1.1': (base.SpecItem.KIND_LTE, 0, 1, 1, None, None), + '<=0.1.1-': (base.SpecItem.KIND_LTE, 0, 1, 1, (), None), '>=0.2.3-rc2': (base.SpecItem.KIND_GTE, 0, 2, 3, ('rc2',), None), '>0.2.3-rc2+': (base.SpecItem.KIND_GT, 0, 2, 3, ('rc2',), ()), '>=2.0.0': (base.SpecItem.KIND_GTE, 2, 0, 0, None, None), diff --git a/tests/test_django.py b/tests/test_django.py index e55ec28..a2d4c9b 100644 --- a/tests/test_django.py +++ b/tests/test_django.py @@ -56,13 +56,16 @@ class DjangoFieldTestCase(unittest.TestCase): obj.full_clean() + def test_partial_spec(self): + obj = models.VersionModel(version='0.1.1', spec='==0,!=0.2') + self.assertEqual(semantic_version.Version('0.1.1'), obj.version) + self.assertEqual(semantic_version.Spec('==0,!=0.2'), obj.spec) + def test_invalid_input(self): self.assertRaises(ValueError, models.VersionModel, version='0.1.1', spec='blah') self.assertRaises(ValueError, models.VersionModel, version='0.1', spec='==0.1.1,!=0.1.1-alpha') - self.assertRaises(ValueError, models.VersionModel, - version='0.1.1', spec='==0,!=0.2') def test_partial(self): obj = models.PartialVersionModel(partial='0.1.0') diff --git a/tests/test_match.py b/tests/test_match.py index e0fd5e7..5f7a988 100755 --- a/tests/test_match.py +++ b/tests/test_match.py @@ -11,7 +11,6 @@ class MatchTestCase(unittest.TestCase): invalid_specs = [ '', '!0.1', - '<0.1', '<=0.1.4a', '>0.1.1.1', '~0.1.2-rc23,1', @@ -20,6 +19,7 @@ class MatchTestCase(unittest.TestCase): valid_specs = [ '==0.1.0', '<=0.1.1', + '<0.1', '>0.1.2-rc1', '>=0.1.2-rc1.3.4', '==0.1.2+build42-12.2012-01-01.12h23', @@ -101,6 +101,20 @@ class MatchTestCase(unittest.TestCase): version = semantic_version.Version('0.1.1-rc1+4.2') self.assertTrue(version in spec, "%r should be in %r" % (version, spec)) + def test_prerelease_check(self): + 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 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') + 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)) + if __name__ == '__main__': # pragma: no cover unittest.main() |