Skip to content
Myr

Add os.environ fixture (#308)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Seth Michael Larson · committed by Florimond Manca · parent 40e6e8c · Browse files · 1 file+24 added−0 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+24 added−0 removed

  • tests:+24 added−0 removed

1 file+24 added−0 removed

modified:tests/conftest.py+24 added
1import asyncio2import os3import threading4import time5import typing67import pytest8import trustme9from cryptography.hazmat.primitives.serialization import (
5 unmodified lines
15from uvicorn.main import Server1617from httpx import URL, AsyncioBackend1819ENVIRONMENT_VARIABLES = (20 "SSL_CERT_FILE",21 "REQUESTS_CA_BUNDLE",22 "CURL_CA_BUNDLE",23 "HTTP_PROXY",24 "HTTPS_PROXY",25 "ALL_PROXY",26 "NO_PROXY",27 "SSLKEYLOGFILE",28)293031@pytest.fixture(scope="function", autouse=True)32def clean_environ() -> typing.Dict[str, typing.Any]:33 """Keeps os.environ clean for every test without having to mock os.environ"""34 original_environ = os.environ.copy()35 for key in ENVIRONMENT_VARIABLES:36 os.environ.pop(key, None)37 yield38 os.environ.clear()39 os.environ.update(original_environ)404142@pytest.fixture(params=[pytest.param(AsyncioBackend, marks=pytest.mark.asyncio)])43def backend(request):44 backend_cls = request.param45 return backend_cls()
204 unmodified lines