Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions tests/integration/async_/test_custom_ssl_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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):
Expand Down
12 changes: 7 additions & 5 deletions tests/integration/examples/test_custom_resolver_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -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[]


Expand Down
4 changes: 3 additions & 1 deletion tests/integration/examples/test_pass_bookmarks_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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()
15 changes: 11 additions & 4 deletions tests/integration/sync/test_custom_ssl_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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):
Expand Down