| 1 |
from __future__ import annotations |
| 2 |
|
| 3 |
from typing import TYPE_CHECKING |
| 4 |
|
| 5 |
import pytest |
| 6 |
import requests |
| 7 |
|
| 8 |
if TYPE_CHECKING: |
| 9 |
from requests_mock import Mocker |
| 10 |
|
| 11 |
|
| 12 |
@pytest.fixture |
| 13 |
def requests_mock(requests_mock, monkeypatch) -> Mocker: |
| 14 |
"""Use plain session wherever MB requests are mocked. |
| 15 |
|
| 16 |
This avoids rate limiting requests to speed up tests. |
| 17 |
""" |
| 18 |
monkeypatch.setattr( |
| 19 |
"beetsplug._utils.musicbrainz.MusicBrainzAPI.create_session", |
| 20 |
lambda _: requests.Session(), |
| 21 |
) |
| 22 |
return requests_mock |