Skip to content

Commit

Permalink
Merge pull request #707 from python-gitlab/fix/python-tests
Browse files Browse the repository at this point in the history
fix: use python2 compatible syntax for super
  • Loading branch information
gpocentek committed Feb 24, 2019
2 parents 39cb97d + b08efcb commit e58d2a8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
9 changes: 7 additions & 2 deletions gitlab/base.py
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
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

0 comments on commit e58d2a8

Please sign in to comment.