Skip to content

Commit

Permalink
Fix Repo comparison on Python 2
Browse files Browse the repository at this point in the history
Python 3 automatically defines the right __ne__ if you define an __eq__,
but Python 2 doesn't.

The comparison operators are only used in unit tests so this is not a
user-visible bug.
  • Loading branch information
mgedmin committed Sep 9, 2019
1 parent 3c86d6b commit bf626dd
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions ghcloneall.py
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,9 @@ def __eq__(self, other):
other.name, other.clone_url, other.urls,
)

def __ne__(self, other):
return not self.__eq__(other)

@classmethod
def from_repo(cls, repo):
# use repo['git_url'] for anonymous checkouts, but they'e slower
Expand Down
3 changes: 3 additions & 0 deletions tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -666,8 +666,11 @@ def test_Repo():
r3 = ghcloneall.Repo('bar', 'git@github.com:test_user/bar.git',
['https://github.com/test_user/bar'])
assert r1 == r2
assert not r1 != r2
assert r1 != r3
assert not r1 == r3
assert r1 != 'foo'
assert not r1 == 'foo'
assert repr(r1) == (
"Repo('foo', 'git@github.com:test_user/foo.git',"
" {'git@github.com:test_user/foo.git',"
Expand Down

0 comments on commit bf626dd

Please sign in to comment.