Support niquests

This commit is contained in:
Timmy Welch 2024-06-09 13:09:26 -07:00
parent c91c7edd73
commit 6132af3bb5
5 changed files with 29 additions and 6 deletions

View File

@ -5,7 +5,10 @@ import os
import pathlib
import stat
import requests
try:
import niquests as requests
except ImportError:
import requests
parser = argparse.ArgumentParser()
parser.add_argument("APPIMAGETOOL", default="build/appimagetool-x86_64.AppImage", type=pathlib.Path, nargs="?")

View File

@ -25,7 +25,10 @@ import sqlite3 as lite
import tempfile
from typing import TYPE_CHECKING
import requests
try:
import niquests as requests
except ImportError:
import requests
from comictaggerlib import ctversion

View File

@ -18,7 +18,10 @@ from __future__ import annotations
import logging
import requests
try:
import niquests as requests
except ImportError:
import requests
from comictaggerlib import ctversion

View File

@ -25,7 +25,6 @@ import time
from typing import Any, Callable, Generic, TypeVar
from urllib.parse import urljoin
import requests
import settngs
from pyrate_limiter import Limiter, RequestRate
from typing_extensions import Required, TypedDict
@ -38,6 +37,10 @@ from comictalker import talker_utils
from comictalker.comiccacher import ComicCacher, Issue, Series
from comictalker.comictalker import ComicTalker, TalkerDataError, TalkerNetworkError
try:
import niquests as requests
except ImportError:
import requests
logger = logging.getLogger(__name__)

View File

@ -10,7 +10,6 @@ from collections.abc import Generator
from typing import Any
import pytest
import requests
import settngs
from PIL import Image
from pyrate_limiter import Limiter, RequestRate
@ -26,6 +25,11 @@ from comicapi import utils
from testing import comicvine, filenames
from testing.comicdata import all_seed_imprints, seed_imprints
try:
import niquests as requests
except ImportError:
import requests
@pytest.fixture
def cbz():
@ -55,7 +59,14 @@ def cbz_double_cover(tmp_path, tmp_comic):
@pytest.fixture(autouse=True)
def no_requests(monkeypatch) -> None:
"""Remove requests.sessions.Session.request for all tests."""
monkeypatch.delattr("requests.sessions.Session.request")
try:
monkeypatch.delattr("niquests.sessions.Session.request")
except Exception:
...
try:
monkeypatch.delattr("requests.sessions.Session.request")
except Exception:
...
@pytest.fixture