Skip to content

Fixes #109 and add iterator to VersionInfo #124

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

Merged
merged 1 commit into from
Mar 24, 2019
Merged
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.werner@ppkt.eu>
* Peter Bittner <django@bittner.it>
* robi-wan <robi-wan@suyu.de>
* T. Jameson Little <t.jameson.little@gmail.com>
Expand Down
6 changes: 6 additions & 0 deletions semver.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,12 @@ def _asdict(self):
("build", self.build)
))

def __iter__(self):
"""Implement iter(self)."""
# As long as we support Py2.7, we can't use the "yield from" syntax
for v in self._astuple():
yield v

@comparator
def __eq__(self, other):
return _compare_by_keys(self._asdict(), _to_dict(other)) == 0
Expand Down
5 changes: 5 additions & 0 deletions test_semver.py
Original file line number Diff line number Diff line change
Expand Up @@ -452,3 +452,8 @@ def test_immutable_unknown_attribute(version):
# "no new attribute can be set"
with pytest.raises(AttributeError):
version.new_attribute = 'forbidden'


def test_version_info_should_be_iterable(version):
assert tuple(version) == (version.major, version.minor, version.patch,
version.prerelease, version.build)