aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWojtek Kosior <koszko@koszko.org>2022-06-15 14:36:18 +0200
committerWojtek Kosior <koszko@koszko.org>2022-06-15 14:36:18 +0200
commit3defc28777c7917139fa74e2f84786194cd6c734 (patch)
treec08c08e89e5310efa7be5998b1b87e9a4c397037
parent89ef5d99f651e8caee49934db2bbd4abefe95d8d (diff)
downloadhaketilo-hydrilla-3defc28777c7917139fa74e2f84786194cd6c734.tar.gz
haketilo-hydrilla-3defc28777c7917139fa74e2f84786194cd6c734.zip
only block 'requests' library for tests if it is present
-rw-r--r--conftest.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/conftest.py b/conftest.py
index 6b6d1cf..37401e8 100644
--- a/conftest.py
+++ b/conftest.py
@@ -9,6 +9,7 @@ from pathlib import Path
import pytest
import pkgutil
+import importlib
import functools
from tempfile import TemporaryDirectory
from typing import Iterable
@@ -19,7 +20,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')
def _mock_subprocess_run(monkeypatch, where, mocked_run):
"""Temporarily replace subprocess.run() with the given function."""