Skip to content

fix: use python2 compatible syntax for super #707

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
Feb 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
9 changes: 7 additions & 2 deletions gitlab/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,16 @@ def __repr__(self):
def __eq__(self, other):
if self.get_id() and other.get_id():
return self.get_id() == other.get_id()
return super().__eq__(other)
return super(RESTObject, self) == other

def __ne__(self, other):
if self.get_id() and other.get_id():
return self.get_id() != other.get_id()
return super(RESTObject, self) != other

def __hash__(self):
if not self.get_id():
return super().__hash__()
return super(RESTObject, self).__hash__()
return hash(self.get_id())

def _create_managers(self):
Expand Down
6 changes: 5 additions & 1 deletion gitlab/tests/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ class ObjectWithManager(FakeObject):
_managers = (('fakes', 'FakeManager'), )

obj = ObjectWithManager(self.manager, {'foo': 'bar'})
obj.id = 42
self.assertIsInstance(obj.fakes, FakeManager)
self.assertEqual(obj.fakes.gitlab, self.gitlab)
self.assertEqual(obj.fakes._parent, obj)
Expand All @@ -145,7 +146,10 @@ class OtherFakeObject(FakeObject):
_id_attr = 'foo'

obj1 = OtherFakeObject(self.manager, {'foo': 'bar'})
obj2 = OtherFakeObject(self.manager, {'foo': 'bar', 'other_attr': 'baz'})
obj2 = OtherFakeObject(
self.manager,
{'foo': 'bar', 'other_attr': 'baz'}
)
self.assertEqual(obj1, obj2)

def test_inequality(self):
Expand Down