From 2fc043b30a492d69bb00912867d6d27541419ebc Mon Sep 17 00:00:00 2001 From: Wojtek Kosior Date: Tue, 14 Jun 2022 13:16:28 +0200 Subject: only block 'requests' library for tests if it is present --- conftest.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/conftest.py b/conftest.py index e41a61d..f49d30f 100644 --- a/conftest.py +++ b/conftest.py @@ -9,6 +9,7 @@ from pathlib import Path import pytest import pkgutil +import importlib from tempfile import TemporaryDirectory from typing import Iterable @@ -18,7 +19,8 @@ sys.path.insert(0, str(here / 'src')) @pytest.fixture(autouse=True) def no_requests(monkeypatch): """Remove requests.sessions.Session.request for all tests.""" - monkeypatch.delattr('requests.sessions.Session.request') + if importlib.util.find_spec("requests") is not None: + monkeypatch.delattr('requests.sessions.Session.request') @pytest.fixture def mock_subprocess_run(monkeypatch, request): -- cgit v1.2.3