mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
parent
e385c91fa5
commit
750adbaa27
3 changed files with 3 additions and 5 deletions
|
@ -205,7 +205,7 @@ class InventoryDirectory(object):
|
|||
# because the __eq__/__ne__ methods in Host() compare the
|
||||
# name fields rather than references, we use id() here to
|
||||
# do the object comparison for merges
|
||||
if id(self.hosts[host.name]) != id(host):
|
||||
if self.hosts[host.name] != host:
|
||||
# different object, merge
|
||||
self._merge_hosts(self.hosts[host.name], host)
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ class Host:
|
|||
def __eq__(self, other):
|
||||
if not isinstance(other, Host):
|
||||
return False
|
||||
return self.name == other.name
|
||||
return id(self) == id(other)
|
||||
|
||||
def __ne__(self, other):
|
||||
return not self.__eq__(other)
|
||||
|
|
|
@ -29,9 +29,7 @@ class TestHost(unittest.TestCase):
|
|||
def test_equality(self):
|
||||
self.assertEqual(self.hostA, self.hostA)
|
||||
self.assertNotEqual(self.hostA, self.hostB)
|
||||
self.assertEqual(self.hostA, Host('a'))
|
||||
# __ne__ is a separate method
|
||||
self.assertFalse(self.hostA != Host('a'))
|
||||
self.assertNotEqual(self.hostA, Host('a'))
|
||||
|
||||
def test_hashability(self):
|
||||
# equality implies the hash values are the same
|
||||
|
|
Loading…
Reference in a new issue