summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRaphaël Barrois <raphael.barrois@polytechnique.org>2019-09-06 13:06:57 +0200
committerRaphaël Barrois <raphael.barrois@polytechnique.org>2019-09-06 13:06:57 +0200
commitf029601524ab56205990aa0a69621a89de04c43a (patch)
tree18fe8c4244440ef8ce1c8a693a4aae4eb65415a6
parent17949b82ac9a1173566c08bab4b254e9d64a7ce1 (diff)
downloadsemantic-version-maint/2.x.tar.gz
Fix Spec.specs for single-term ranges.maint/2.x
This (deprecated) property failed when used on a `Spec` item based on a single-term range (e.g. `==0.1.2` `<2.0.0`). Closes #82.
-rw-r--r--ChangeLog6
-rw-r--r--semantic_version/base.py6
-rwxr-xr-xtests/test_base.py7
3 files changed, 14 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index 5aeee68..49cb45d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -4,7 +4,11 @@ ChangeLog
2.8.2 (unreleased)
------------------
-- Nothing changed yet.
+*Bugfix:*
+
+ * `#82 <https://github.com/rbarrois/python-semanticversion/issues/82>`_:
+ Restore computation of ``Spec.specs`` for single-term expressions
+ (``>=0.1.2``)
2.8.1 (2019-08-29)
diff --git a/semantic_version/base.py b/semantic_version/base.py
index dc5e21e..078d83d 100644
--- a/semantic_version/base.py
+++ b/semantic_version/base.py
@@ -1166,7 +1166,11 @@ class LegacySpec(SimpleSpec):
DeprecationWarning,
stacklevel=2,
)
- for clause in self.clause:
+ try:
+ clauses = list(self.clause)
+ except TypeError: # Not an iterable
+ clauses = [self.clause]
+ for clause in clauses:
yield SpecItem.from_matcher(clause)
diff --git a/tests/test_base.py b/tests/test_base.py
index cd0b5f5..2c0830f 100755
--- a/tests/test_base.py
+++ b/tests/test_base.py
@@ -606,6 +606,10 @@ class SpecTestCase(unittest.TestCase):
examples = {
'>=0.1.1,<0.1.2': ['>=0.1.1', '<0.1.2'],
'>=0.1.0,!=0.1.3-rc1,<0.1.3': ['>=0.1.0', '!=0.1.3-rc1', '<0.1.3'],
+ '=0.1.2': ['==0.1.2'],
+ '>=0.1.2': ['>=0.1.2'],
+ '^1.2.3': ['>=1.2.3', '<2.0.0'],
+ '~=1.2.3': ['>=1.2.3', '<1.3.0'],
}
def test_parsing(self):
@@ -617,9 +621,6 @@ class SpecTestCase(unittest.TestCase):
self.assertNotEqual(spec_list_text, spec_list)
self.assertCountEqual(specs, [str(spec) for spec in spec_list])
- for spec_text in specs:
- self.assertIn(str(base.SpecItem(spec_text)), repr(spec_list))
-
split_examples = {
('>=0.1.1', '<0.1.2', '!=0.1.1+build1'): ['>=0.1.1', '<0.1.2', '!=0.1.1+build1'],
('>=0.1.0', '!=0.1.3-rc1,<0.1.3'): ['>=0.1.0', '!=0.1.3-rc1', '<0.1.3'],