diff --git a/neo4j/io/__init__.py b/neo4j/io/__init__.py index ab51b292..2e758a7f 100644 --- a/neo4j/io/__init__.py +++ b/neo4j/io/__init__.py @@ -239,23 +239,24 @@ def version_list(cls, versions, limit=4): returned is limited to four. """ ranges_supported = versions[0] >= Version(4, 3) + without_changes = {Version(4, 2)} if versions and ranges_supported: start, end = 0, 0 first_major = versions[start][0] minors = [] - for end, version in enumerate(versions): + for version in versions: if version[0] == first_major: minors.append(version[1]) else: break - new_versions = ([Version(first_major, minors)] + versions[1:end])[:(limit - 1)] - try: - new_versions.append(versions[end]) - except IndexError: - pass - return new_versions + new_versions = [ + Version(first_major, minors), + *(v for v in versions[1:] if v not in without_changes) + ] else: - return versions[:limit] + new_versions = [v for v in versions if v not in without_changes] + new_versions = [*new_versions[:(limit - 1)], versions[-1]] + return new_versions @classmethod def get_handshake(cls): diff --git a/tests/unit/io/test_class_bolt.py b/tests/unit/io/test_class_bolt.py index 2ffe77f2..7a27b6fb 100644 --- a/tests/unit/io/test_class_bolt.py +++ b/tests/unit/io/test_class_bolt.py @@ -53,7 +53,7 @@ def test_class_method_protocol_handlers_with_invalid_protocol_version(): def test_class_method_get_handshake(): # python -m pytest tests/unit/io/test_class_bolt.py -s -v -k test_class_method_get_handshake handshake = Bolt.get_handshake() - assert handshake == b"\x00\x03\x03\x04\x00\x00\x02\x04\x00\x00\x01\x04\x00\x00\x00\x03" + assert handshake == b"\x00\x03\x03\x04\x00\x00\x01\x04\x00\x00\x00\x04\x00\x00\x00\x03" def test_magic_preamble():