test: delete slow, timing-based and redundant tests

This commit is contained in:
imSp4rky
2026-12-05 15:20:05 -07:00
parent 783a2fc185
commit 3a0a74e694
292 changed files with 153 additions and 15174 deletions
-77
View File
@@ -16,7 +16,6 @@ from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer
import pytest
from requests import Session
from requests.adapters import HTTPAdapter
from requests.auth import HTTPBasicAuth
from tests.core.test_session_verify import self_signed_url as self_signed_url
@@ -55,30 +54,6 @@ def test_rnet_spec_round_trips_cookie_domains() -> None:
assert rebuilt.cookies.get_dict(domain="localhost") == {}
def test_rnet_spec_keeps_dict_set_cookies() -> None:
ns = rnet_session_with_cookies()
spec = build_session_spec(ns)
assert spec is not None
rebuilt = rebuild_session(spec, 1)
assert rebuilt is not None
assert rebuilt.cookies["loose"] == "ghi"
def test_rnet_spec_cookies_carry_domain_information() -> None:
ns = rnet_session_with_cookies()
spec = build_session_spec(ns)
assert spec is not None
assert {(c.domain, c.path, c.name, c.value) for c in spec["cookies"]} == {
("cdn.example.com", "/", "cdn_token", "abc"),
("api.example.com", "/", "api_token", "def"),
("", "/", "loose", "ghi"),
}
def test_rnet_spec_keeps_same_name_cookies_on_their_paths() -> None:
"""Same-name cookies on two paths must reach a child apart, or a stale one goes to every path."""
ns = make_session("Chrome131")
@@ -94,20 +69,6 @@ def test_rnet_spec_keeps_same_name_cookies_on_their_paths() -> None:
assert rebuilt.cookies.get("hdntl", path="/t/2") == "two"
def test_rnet_spec_is_picklable() -> None:
spec = build_session_spec(rnet_session_with_cookies())
assert spec is not None
loaded = pickle.loads(pickle.dumps(spec))
# stdlib Cookie has no __eq__, so compare the cookies by their fields
assert [vars(c) for c in loaded.pop("cookies")] == [vars(c) for c in spec.pop("cookies")]
assert loaded == spec
def test_rnet_spec_without_impersonate_is_not_rebuildable() -> None:
assert build_session_spec(RnetSession()) is None
class _CookieHandler(BaseHTTPRequestHandler):
"""Sets one cookie on /set and echoes the Cookie header it receives on /echo."""
@@ -168,22 +129,6 @@ def test_rebuilt_requests_session_pool_is_sized_to_worker_count() -> None:
assert adapter.poolmanager.connection_pool_kw["maxsize"] == 24
def test_rebuilt_rnet_session_has_no_adapters() -> None:
"""rnet pools internally; the sizing fix must not reach into that path."""
spec = build_session_spec(rnet_session_with_cookies())
assert spec is not None
rebuilt = rebuild_session(spec, 24)
assert rebuilt is not None
assert not isinstance(rebuilt, Session)
assert not hasattr(rebuilt, "adapters")
def test_unrebuildable_spec_stays_none() -> None:
assert rebuild_session({"kind": "none"}, 24) is None
def test_requests_spec_round_trips_cookie_domains() -> None:
rs = Session()
rs.cookies.set("cdn_token", "abc", domain="cdn.example.com")
@@ -270,18 +215,6 @@ def test_requests_spec_carries_cert_and_auth() -> None:
assert rebuilt.auth == HTTPBasicAuth("user", "pass")
def test_requests_spec_is_picklable() -> None:
rs = Session()
rs.verify = False
rs.params = {"at": "auth-token"}
rs.cookies.set("cdn_token", "abc", domain="cdn.example.com")
spec = build_session_spec(rs)
assert spec is not None
assert pickle.loads(pickle.dumps(spec))["params"] == {"at": "auth-token"}
def test_requests_spec_with_unpicklable_auth_is_not_rebuildable() -> None:
"""auth takes any callable. One that spawn cannot pickle has to fall back, not kill the child."""
rs = Session()
@@ -303,13 +236,3 @@ def test_mounted_ssl_ciphers_is_not_rebuildable() -> None:
rs.mount("https://cdn.example.com", SSLCiphers(security_level=2))
assert build_session_spec(rs) is None
def test_rebuilt_requests_session_mounts_a_plain_adapter() -> None:
"""The spec only ever describes a plain adapter, so the child must not appear to hold more than that."""
spec = build_session_spec(Session())
assert spec is not None
rebuilt = rebuild_session(spec, 4)
assert rebuilt is not None
assert type(rebuilt.get_adapter("https://example.com")) is HTTPAdapter