-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathconftest.py
More file actions
33 lines (25 loc) · 891 Bytes
/
conftest.py
File metadata and controls
33 lines (25 loc) · 891 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
from collections.abc import Iterable, Iterator
from logging import getLogger
import pytest
from pytest_httpserver import HTTPServer
@pytest.fixture(scope='session')
def make_httpserver() -> Iterable[HTTPServer]:
werkzeug_logger = getLogger('werkzeug')
werkzeug_logger.disabled = True
server = HTTPServer(threaded=True, host='127.0.0.1')
server.start()
yield server
server.clear()
if server.is_running():
server.stop()
@pytest.fixture
def httpserver(make_httpserver: HTTPServer) -> Iterable[HTTPServer]:
server = make_httpserver
yield server
server.clear()
@pytest.fixture
def patch_basic_url(httpserver: HTTPServer, monkeypatch: pytest.MonkeyPatch) -> Iterator[None]:
server_url = httpserver.url_for('/').removesuffix('/')
monkeypatch.setattr('apify_client.client.DEFAULT_API_URL', server_url)
yield
monkeypatch.undo()