From 5fe25b5c047dcda10d2adcd44ce5b2ed8a91d7bb Mon Sep 17 00:00:00 2001 From: Avasam Date: Mon, 16 Sep 2024 22:34:45 -0400 Subject: [PATCH] Replace pytest.raises with try-except-else --- setuptools/tests/test_distutils_adoption.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/setuptools/tests/test_distutils_adoption.py b/setuptools/tests/test_distutils_adoption.py index 31160271ca..d65f65ec74 100644 --- a/setuptools/tests/test_distutils_adoption.py +++ b/setuptools/tests/test_distutils_adoption.py @@ -160,12 +160,17 @@ def test_log_module_is_not_duplicated_on_import(distutils_version, venv): ENSURE_CONSISTENT_ERROR_FROM_MODIFIED_PY = r""" -import pytest from setuptools.modified import newer from distutils.error import DistutilsError -with pytest.raises(DistutilsError): +# Can't use pytest.raises in this context +try: newer("", "") +except DistutilsError: + pass +else: + raise AssertionError("Expected to raise") + """