diff --git a/CONTRIBUTORS b/CONTRIBUTORS index ce0b166c..0c441cb4 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -29,7 +29,7 @@ Significant contributors * Craig Blaszczyk * Jan Pieter Waagmeester * Jelo Agnasin -* Karol Werner +* Karol Werner * Peter Bittner * robi-wan * T. Jameson Little diff --git a/semver.py b/semver.py index 5f5be2c2..fbd564e3 100644 --- a/semver.py +++ b/semver.py @@ -124,6 +124,10 @@ def _asdict(self): ("build", self.build) )) + def __iter__(self): + for v in self._astuple(): + yield v + def __eq__(self, other): if not isinstance(other, (VersionInfo, dict)): return NotImplemented diff --git a/test_semver.py b/test_semver.py index c8532202..436f834d 100644 --- a/test_semver.py +++ b/test_semver.py @@ -460,3 +460,9 @@ def test_immutable(): pass else: assert 0, "no new attribute can be set" + + +def test_version_info_should_be_iterable(): + v = VersionInfo(major=1, minor=2, patch=3, + prerelease='alpha.1.2', build='build.11.e0f985a') + assert tuple(v) == v._astuple()