/
niceSOFT
/
python3-urllib3
Обзор
Документация
Войти
/
niceSOFT
/
python3-urllib3
Код
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
test/test_queue_monkeypatch.py
29 строк
761 B
Bastian Venthur
Use the typing namespace and from __future__ import annotations
21 ноя 2022, 22:29
Не верифицирован
21 ноя 2022, 22:29
fe39ebf
Код
Авторство
О чём код?
from __future__ import annotations import queue from unittest import mock import pytest from urllib3 import HTTPConnectionPool from urllib3.exceptions import EmptyPoolError class BadError(Exception): """ This should not be raised. """ class TestMonkeypatchResistance: """ Test that connection pool works even with a monkey patched Queue module, see obspy/obspy#1599, psf/requests#3742, urllib3/urllib3#1061. """ def test_queue_monkeypatching(self) -> None: with mock.patch.object(queue, "Empty", BadError): with HTTPConnectionPool(host="localhost", block=True) as http: http._get_conn() with pytest.raises(EmptyPoolError): http._get_conn(timeout=0)