summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorRaphaël Barrois <raphael.barrois@polytechnique.org>2012-05-15 00:23:21 +0200
committerRaphaël Barrois <raphael.barrois@polytechnique.org>2012-05-15 00:23:21 +0200
commite57e90d86ec1edf21cde6f0a4da56ac6273fedbc (patch)
tree9096fb8fa4166de597decfc1ac8ce4df824e834c /tests
parent8a52f092379ae2f8c45de385cb13ab6a9f2d9017 (diff)
downloadsemantic-version-e57e90d86ec1edf21cde6f0a4da56ac6273fedbc.tar.gz
Full coverage.
Signed-off-by: Raphaël Barrois <raphael.barrois@polytechnique.org>
Diffstat (limited to 'tests')
-rwxr-xr-xtests/test_base.py14
-rwxr-xr-xtests/test_match.py25
-rwxr-xr-xtests/test_parsing.py6
3 files changed, 42 insertions, 3 deletions
diff --git a/tests/test_base.py b/tests/test_base.py
index f89e750..0543744 100755
--- a/tests/test_base.py
+++ b/tests/test_base.py
@@ -91,6 +91,11 @@ class SemanticVersionTestCase(unittest.TestCase):
for field in fields:
self.assertIn(repr(field), repr(version))
+ def test_compare_to_self(self):
+ for text in self.versions:
+ self.assertEqual(base.SemanticVersion(text), base.SemanticVersion(text))
+ self.assertNotEqual(text, base.SemanticVersion(text))
+
partial_versions = {
'1.0': (1, 0, None, None, None),
'1': (1, None, None, None, None),
@@ -128,6 +133,13 @@ class SemanticVersionTestCase(unittest.TestCase):
for field in fields:
self.assertIn(repr(field), repr(version))
+ def test_compare_partial_to_self(self):
+ for text in self.partial_versions:
+ self.assertEqual(
+ base.SemanticVersion(text, partial=True),
+ base.SemanticVersion(text, partial=True))
+ self.assertNotEqual(text, base.SemanticVersion(text, partial=True))
+
-if __name__ == '__main__':
+if __name__ == '__main__': # pragma: no cover
unittest.main()
diff --git a/tests/test_match.py b/tests/test_match.py
index 64011b1..5c042f5 100755
--- a/tests/test_match.py
+++ b/tests/test_match.py
@@ -8,6 +8,8 @@ import semantic_version
class MatchTestCase(unittest.TestCase):
invalid_specs = [
+ '',
+ '!0.1',
'<0.1',
'<=0.1.4a',
'>0.1.1.1',
@@ -41,6 +43,26 @@ class MatchTestCase(unittest.TestCase):
'0.1.1',
'0.1.2-rc1',
'0.1.2-rc1.3.4',
+ '0.1.2',
+ ],
+ '<0.1.2': [
+ '0.1.1',
+ '0.1.2-rc1',
+ '0.1.2-rc1.3.4',
+ '0.1.2-rc1+build4.5',
+ ],
+ '>=0.1.1': [
+ '0.1.1',
+ '0.1.1+build4.5',
+ '0.1.2-rc1.3',
+ '0.2.0',
+ '1.0.0',
+ ],
+ '>0.1.1': [
+ '0.1.1+build4.5',
+ '0.1.2-rc1.3',
+ '0.2.0',
+ '1.0.0',
],
}
@@ -60,8 +82,9 @@ class MatchTestCase(unittest.TestCase):
version = semantic_version.SemanticVersion(version_txt)
self.assertTrue(spec.match(version), "%r does not match %r" % (version, spec))
+ self.assertTrue(semantic_version.match(spec_txt, version_txt))
-if __name__ == '__main__':
+if __name__ == '__main__': # pragma: no cover
unittest.main()
diff --git a/tests/test_parsing.py b/tests/test_parsing.py
index cdf21fc..b59b8a3 100755
--- a/tests/test_parsing.py
+++ b/tests/test_parsing.py
@@ -8,6 +8,9 @@ import semantic_version
class ParsingTestCase(unittest.TestCase):
invalids = [
+ None,
+ '',
+ '0',
'0.1',
'0.1.4a',
'0.1.1.1',
@@ -58,7 +61,8 @@ class ComparisonTestCase(unittest.TestCase):
self.assertTrue(first_ver == second_ver, '%r != %r' % (first_ver, second_ver))
else:
self.assertTrue(first_ver > second_ver, '%r !> %r' % (first_ver, second_ver))
+ self.assertEqual(cmp(i, j), semantic_version.compare(first, second))
-if __name__ == '__main__':
+if __name__ == '__main__': # pragma: no cover
unittest.main()