summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRaphaël Barrois <raphael.barrois@polyconseil.fr>2012-05-22 09:46:28 +0200
committerRaphaël Barrois <raphael.barrois@polyconseil.fr>2012-05-22 09:46:28 +0200
commit9e58282b8baf892b8eea19d3d232f96017e42a0b (patch)
tree1b3da318aac18a02379864ad3080fb8e94f552fc
parent7e85ad59cf601967b8cdd49e305f88024ced18f0 (diff)
downloadsemantic-version-9e58282b8baf892b8eea19d3d232f96017e42a0b.tar.gz
Add a few tests.
Signed-off-by: Raphaël Barrois <raphael.barrois@polyconseil.fr>
-rw-r--r--doc/reference.rst2
-rw-r--r--src/semantic_version/base.py2
-rwxr-xr-xtests/test_base.py30
3 files changed, 32 insertions, 2 deletions
diff --git a/doc/reference.rst b/doc/reference.rst
index 6ac06e0..bd11189 100644
--- a/doc/reference.rst
+++ b/doc/reference.rst
@@ -190,7 +190,7 @@ Representing a version (the Version class)
Version specifications (the Spec class)
--------------------------------------------
+---------------------------------------
Version specifications describe a 'range' of accepted versions:
diff --git a/src/semantic_version/base.py b/src/semantic_version/base.py
index 67ffe92..ba37f27 100644
--- a/src/semantic_version/base.py
+++ b/src/semantic_version/base.py
@@ -128,7 +128,7 @@ class Version(object):
def __repr__(self):
return '<%sVersion(%s, %s, %s, %r, %r)>' % (
- ', partial=True' if self.partial else '',
+ '~' if self.partial else '',
self.major,
self.minor,
self.patch,
diff --git a/tests/test_base.py b/tests/test_base.py
index 9bc19e8..6ea832a 100755
--- a/tests/test_base.py
+++ b/tests/test_base.py
@@ -59,6 +59,36 @@ class ComparisonTestCase(unittest.TestCase):
a, b, result, expected))
+class TopLevelTestCase(unittest.TestCase):
+ """Test module-level functions."""
+
+ versions = (
+ ('0.1.0', '0.1.1', -1),
+ ('0.1.1', '0.1.1', 0),
+ ('0.1.1', '0.1.0', 1),
+ ('0.1.0-alpha', '0.1.0', -1),
+ ('0.1.0-alpha+2', '0.1.0-alpha', 1),
+ )
+
+ def test_compare(self):
+ for a, b, expected in self.versions:
+ result = base.compare(a, b)
+ self.assertEqual(expected, result,
+ "compare(%r, %r) should be %r instead of %r" % (a, b, expected, result))
+
+ matches = (
+ ('>=0.1.1', '0.1.2'),
+ ('>=0.1.1', '0.1.1'),
+ ('>=0.1.1', '0.1.1-alpha'),
+ ('>=0.1.1,!=0.2.0', '0.2.1'),
+ )
+
+ def test_match(self):
+ for spec, version in self.matches:
+ self.assertTrue(base.match(spec, version),
+ "%r should accept %r" % (spec, version))
+
+
class VersionTestCase(unittest.TestCase):
versions = {
'1.0.0-alpha': (1, 0, 0, ('alpha',), ()),