summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorRaphaël Barrois <raphael.barrois@polytechnique.org>2013-03-21 22:31:49 +0100
committerRaphaël Barrois <raphael.barrois@polytechnique.org>2013-03-21 22:31:49 +0100
commita9dae494c1de1271bf75b8aacb2a52b4bcaa5a67 (patch)
tree554628954c9969eb32077373c1ab61b278c48399 /tests
parent712d74f87c07c60f2e1d27b44915d5d4bb941fe7 (diff)
downloadsemantic-version-a9dae494c1de1271bf75b8aacb2a52b4bcaa5a67.tar.gz
Add semantic_version.validate (Closes #2).
Simple way of testing whether a string is a 'valid' SemVer version. Signed-off-by: Raphaël Barrois <raphael.barrois@polytechnique.org>
Diffstat (limited to 'tests')
-rwxr-xr-xtests/test_base.py40
1 files changed, 40 insertions, 0 deletions
diff --git a/tests/test_base.py b/tests/test_base.py
index 3e10a83..1feb14f 100755
--- a/tests/test_base.py
+++ b/tests/test_base.py
@@ -88,6 +88,46 @@ class TopLevelTestCase(unittest.TestCase):
self.assertTrue(base.match(spec, version),
"%r should accept %r" % (spec, version))
+ valid_strings = (
+ '1.0.0-alpha',
+ '1.0.0-alpha.1',
+ '1.0.0-beta.2',
+ '1.0.0-beta.11',
+ '1.0.0-rc.1',
+ '1.0.0-rc.1+build.1',
+ '1.0.0',
+ '1.0.0+0.3.7',
+ '1.3.7+build',
+ '1.3.7+build.2.b8f12d7',
+ '1.3.7+build.11.e0f985a',
+ '1.1.1',
+ '1.1.2',
+ '1.1.3-rc4.5',
+ '1.1.3-rc42.3-14-15.24+build.2012-04-13.223',
+ '1.1.3+build.2012-04-13.HUY.alpha-12.1',
+ )
+
+ def test_validate_valid(self):
+ for version in self.valid_strings:
+ self.assertTrue(base.validate(version),
+ "%r should be a valid version" % (version,))
+
+ invalid_strings = (
+ '1',
+ 'v1',
+ '1.2.3.4',
+ '1.2',
+ '1.2a3',
+ '1.2.3a4',
+ 'v12.34.5',
+ '1.2.3+4+5',
+ )
+
+ def test_validate_invalid(self):
+ for version in self.invalid_strings:
+ self.assertFalse(base.validate(version),
+ "%r should not be a valid version" % (version,))
+
class VersionTestCase(unittest.TestCase):
versions = {