diff --git a/tests/integration/async_/test_custom_ssl_context.py b/tests/integration/async_/test_custom_ssl_context.py index 4bc52f728..396b3a2b8 100644 --- a/tests/integration/async_/test_custom_ssl_context.py +++ b/tests/integration/async_/test_custom_ssl_context.py @@ -19,9 +19,11 @@ import pytest -from neo4j import AsyncGraphDatabase +import neo4j +from neo4j._async_compat.util import AsyncUtil from ..._async_compat import mark_async_test +from ...conftest import get_async_driver_no_warning @mark_async_test @@ -39,9 +41,14 @@ def wrap_fail(*_, **__): fake_ssl_context.wrap_socket.side_effect = wrap_fail fake_ssl_context.wrap_bio.side_effect = wrap_fail - driver = AsyncGraphDatabase.driver( - uri, auth=auth, ssl_context=fake_ssl_context - ) + if AsyncUtil.is_async_code: + driver = get_async_driver_no_warning( + uri, auth=auth, ssl_context=fake_ssl_context + ) + else: + driver = neo4j.GraphDatabase.driver( + uri, auth=auth, ssl_context=fake_ssl_context + ) async with driver: async with driver.session() as session: with pytest.raises(NoNeedToGoFurtherException): diff --git a/tests/integration/examples/test_custom_resolver_example.py b/tests/integration/examples/test_custom_resolver_example.py index a4e762a37..928fa1624 100644 --- a/tests/integration/examples/test_custom_resolver_example.py +++ b/tests/integration/examples/test_custom_resolver_example.py @@ -50,11 +50,13 @@ def resolver(address): def add_person(name): - driver = create_driver("neo4j://x.example.com", user="neo4j", password="password") - session = driver.session(default_access_mode=WRITE_ACCESS) - session.run("CREATE (a:Person {name: $name})", {"name", name}) - session.close() - driver.close() + driver = create_driver("neo4j://x.example.com", + user="neo4j", password="password") + try: + with driver.session(default_access_mode=WRITE_ACCESS) as session: + session.run("CREATE (a:Person {name: $name})", {"name", name}) + finally: + driver.close() # end::custom-resolver[] diff --git a/tests/integration/examples/test_pass_bookmarks_example.py b/tests/integration/examples/test_pass_bookmarks_example.py index c5e823ebb..a9ca6c4ab 100644 --- a/tests/integration/examples/test_pass_bookmarks_example.py +++ b/tests/integration/examples/test_pass_bookmarks_example.py @@ -96,8 +96,8 @@ def main(self): def test(uri, auth): + eg = BookmarksExample(uri, auth) try: - eg = BookmarksExample(uri, auth) with eg.driver.session() as session: session.run("MATCH (_) DETACH DELETE _") eg.main() @@ -106,3 +106,5 @@ def test(uri, auth): except ServiceUnavailable as error: if isinstance(error.__cause__, BoltHandshakeError): pytest.skip(error.args[0]) + finally: + eg.close() diff --git a/tests/integration/sync/test_custom_ssl_context.py b/tests/integration/sync/test_custom_ssl_context.py index 56d09f684..93e7b2777 100644 --- a/tests/integration/sync/test_custom_ssl_context.py +++ b/tests/integration/sync/test_custom_ssl_context.py @@ -19,9 +19,11 @@ import pytest -from neo4j import GraphDatabase +import neo4j +from neo4j._async_compat.util import Util from ..._async_compat import mark_sync_test +from ...conftest import get_async_driver_no_warning @mark_sync_test @@ -39,9 +41,14 @@ def wrap_fail(*_, **__): fake_ssl_context.wrap_socket.side_effect = wrap_fail fake_ssl_context.wrap_bio.side_effect = wrap_fail - driver = GraphDatabase.driver( - uri, auth=auth, ssl_context=fake_ssl_context - ) + if Util.is_async_code: + driver = get_async_driver_no_warning( + uri, auth=auth, ssl_context=fake_ssl_context + ) + else: + driver = neo4j.GraphDatabase.driver( + uri, auth=auth, ssl_context=fake_ssl_context + ) with driver: with driver.session() as session: with pytest.raises(NoNeedToGoFurtherException):