Skip to content

Commit e45cd66

Browse files
committed
Unit tests: make work with pytest 8
In pytest 8 changed the warns assertion was changed to also check for warnings if an error was raised. This used to be different, and the test suite relied (unnecessarily) on this behavior. See also pytest-dev/pytest#9036
1 parent f2b90f7 commit e45cd66

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

tests/unit/async_/test_driver.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,8 @@ async def test_routing_driver_constructor(protocol, host, port, params, auth_tok
168168
async def test_driver_config_error_uri_conflict(
169169
test_uri, test_config, expected_failure, expected_failure_message
170170
):
171-
def driver_builder():
172-
if "trust" in test_config:
171+
def driver_builder(expect_failure=False):
172+
if "trust" in test_config and not expect_failure:
173173
with pytest.warns(DeprecationWarning, match="trust"):
174174
return AsyncGraphDatabase.driver(test_uri, **test_config)
175175
else:
@@ -179,7 +179,7 @@ def driver_builder():
179179
# `+s` and `+ssc` are shorthand syntax for not having to configure the
180180
# encryption behavior of the driver. Specifying both is invalid.
181181
with pytest.raises(expected_failure, match=expected_failure_message):
182-
driver_builder()
182+
driver_builder(expect_failure=True)
183183
else:
184184
driver = driver_builder()
185185
await driver.close()

tests/unit/sync/test_driver.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,8 @@ def test_routing_driver_constructor(protocol, host, port, params, auth_token):
167167
def test_driver_config_error_uri_conflict(
168168
test_uri, test_config, expected_failure, expected_failure_message
169169
):
170-
def driver_builder():
171-
if "trust" in test_config:
170+
def driver_builder(expect_failure=False):
171+
if "trust" in test_config and not expect_failure:
172172
with pytest.warns(DeprecationWarning, match="trust"):
173173
return GraphDatabase.driver(test_uri, **test_config)
174174
else:
@@ -178,7 +178,7 @@ def driver_builder():
178178
# `+s` and `+ssc` are shorthand syntax for not having to configure the
179179
# encryption behavior of the driver. Specifying both is invalid.
180180
with pytest.raises(expected_failure, match=expected_failure_message):
181-
driver_builder()
181+
driver_builder(expect_failure=True)
182182
else:
183183
driver = driver_builder()
184184
driver.close()

0 commit comments

Comments
 (0)