Skip to content

Add possibility to iterate over VersionInfo #109

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CONTRIBUTORS
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Significant contributors
* Craig Blaszczyk <masterjakul@gmail.com>
* Jan Pieter Waagmeester <jieter@jieter.nl>
* Jelo Agnasin <jelo@icannhas.com>
* Karol Werner <karol.werner@codete.co>
* Karol Werner <karol@ppkt.eu>
* Peter Bittner <django@bittner.it>
* robi-wan <robi-wan@suyu.de>
* T. Jameson Little <t.jameson.little@gmail.com>
Expand Down
4 changes: 4 additions & 0 deletions semver.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions test_semver.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()