File: plugin.py

package info (click to toggle)
pytest-httpbin 2.1.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 176 kB
  • sloc: python: 312; sh: 18; makefile: 14
file content (39 lines) | stat: -rw-r--r-- 979 bytes parent folder | download
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
34
35
36
37
38
39
import pytest
from httpbin import app as httpbin_app

from . import certs, serve


@pytest.fixture(scope="session")
def httpbin(request):
    with serve.Server(application=httpbin_app) as server:
        yield server


@pytest.fixture(scope="session")
def httpbin_secure(request):
    with serve.SecureServer(application=httpbin_app) as server:
        yield server


@pytest.fixture(scope="session", params=["http", "https"])
def httpbin_both(request, httpbin, httpbin_secure):
    if request.param == "http":
        return httpbin
    elif request.param == "https":
        return httpbin_secure


@pytest.fixture(scope="class")
def class_based_httpbin(request, httpbin):
    request.cls.httpbin = httpbin


@pytest.fixture(scope="class")
def class_based_httpbin_secure(request, httpbin_secure):
    request.cls.httpbin_secure = httpbin_secure


@pytest.fixture(scope="function")
def httpbin_ca_bundle(monkeypatch):
    monkeypatch.setenv("REQUESTS_CA_BUNDLE", certs.where())