Skip to content

Commit 2e1ae4d

Browse files
committed
Fixed Address constructor returning same instance
1 parent d36334e commit 2e1ae4d

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

neo4j/addressing.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ def parse_list(cls, *s, default_host=None, default_port=None):
7070
for a in " ".join(s).split()]
7171

7272
def __new__(cls, iterable):
73-
if type(iterable) is cls:
74-
return cls
73+
if isinstance(iterable, cls):
74+
return iterable
7575
n_parts = len(iterable)
7676
inst = tuple.__new__(cls, iterable)
7777
if n_parts == 2:

tests/unit/test_addressing.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,9 @@ def test_should_error_when_value_missing(self):
5555
def test_should_error_when_key_duplicate(self):
5656
with self.assertRaises(ValueError):
5757
GraphDatabase._parse_routing_context("name=molly&name=white")
58+
59+
60+
def test_address_init_with_address_object_returns_same_instance():
61+
a = Address(("localhost", 7687))
62+
b = Address(a)
63+
assert id(a) == id(b)

0 commit comments

Comments
 (0)