summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorRaphaël Barrois <raphael.barrois@polytechnique.org>2019-08-18 17:41:33 +0200
committerRaphaël Barrois <raphael.barrois@polytechnique.org>2019-08-24 15:13:09 +0200
commita5cc0fb509b2c515ae73c85f9a4d426a3f9100e3 (patch)
tree2beb1ad109f28f995b293a548da4ef76818b7bc3 /tests
parentfdef1e9cdae901d095d8e8c9cd6fa6adcfe02074 (diff)
downloadsemantic-version-a5cc0fb509b2c515ae73c85f9a4d426a3f9100e3.tar.gz
Allow Version(major=1, ...).
Eases the creation of version objects from existing versions. We still validate the type and structure of each component.
Diffstat (limited to 'tests')
-rwxr-xr-xtests/test_parsing.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/test_parsing.py b/tests/test_parsing.py
index 8fd22da..af99d05 100755
--- a/tests/test_parsing.py
+++ b/tests/test_parsing.py
@@ -28,6 +28,15 @@ class ParsingTestCase(unittest.TestCase):
'0.1.2-rc1.3-14.15+build.2012-01-01.11h34',
]
+ valid_fields = [
+ ('0.1.1', [0, 1, 1, (), ()]),
+ ('0.1.1', [0, 1, 1, None, None]),
+ ('0.1.2-rc1', [0, 1, 2, ('rc1',), ()]),
+ ('0.1.2-rc1.3.4', [0, 1, 2, ('rc1', '3', '4'), ()]),
+ ('0.1.2+build42-12.2012-01-01.12h23', [0, 1, 2, (), ('build42-12', '2012-01-01', '12h23')]),
+ ('0.1.2-rc1.3-14.15+build.2012-01-01.11h34', [0, 1, 2, ('rc1', '3-14', '15'), ('build', '2012-01-01', '11h34')]),
+ ]
+
def test_invalid(self):
for invalid in self.invalids:
self.assertRaises(ValueError, semantic_version.Version, invalid)
@@ -37,6 +46,18 @@ class ParsingTestCase(unittest.TestCase):
version = semantic_version.Version(valid)
self.assertEqual(valid, str(version))
+ def test_kwargs(self):
+ for text, fields in self.valid_fields:
+ major, minor, patch, prerelease, build = fields
+ version = semantic_version.Version(
+ major=major,
+ minor=minor,
+ patch=patch,
+ prerelease=prerelease,
+ build=build,
+ )
+ self.assertEqual(text, str(version))
+
class ComparisonTestCase(unittest.TestCase):
order = [