From eeb134d05645fb18271e973d6d1dfb1643735013 Mon Sep 17 00:00:00 2001 From: Erik Sundell Date: Fri, 20 Sep 2024 14:36:39 +0200 Subject: [PATCH] tests: adjust to use pytest.raises --- ldapauthenticator/tests/test_ldapauthenticator.py | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/ldapauthenticator/tests/test_ldapauthenticator.py b/ldapauthenticator/tests/test_ldapauthenticator.py index b3f645d..e32b690 100644 --- a/ldapauthenticator/tests/test_ldapauthenticator.py +++ b/ldapauthenticator/tests/test_ldapauthenticator.py @@ -5,6 +5,7 @@ https://github.com/rroemhild/docker-test-openldap?tab=readme-ov-file#ldap-structure """ +import pytest from ldap3.core.exceptions import LDAPSSLConfigurationError from ..ldapauthenticator import TlsStrategy @@ -200,13 +201,7 @@ async def test_ldap_tls_kwargs_config_passthrough(authenticator): authenticator.tls_kwargs = { "ca_certs_file": "does-not-exist-so-error-expected", } - try: + with pytest.raises(LDAPSSLConfigurationError): await authenticator.get_authenticated_user( None, {"username": "leela", "password": "leela"} ) - except LDAPSSLConfigurationError: - pass - else: - raise ValueError( - "Expected configuring tls_kwargs.ca_certs_file to a non-existing file to raise an error" - )