TestTimeout abandons three delay/10 requests and later tests wait out the server

Aperta Adatta ai principianti
#7,631 6 commenti 0 reazioni 0 assegnatari Vedi su GitHub

@hananbahi527 ci sta già lavorando.

Dal 14/10/2026.

Valutazione

Difficoltà
1/5
Tempo stimato
Meno di un'ora
Idoneità per principianti
90/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
python
Ambito
testing-qa

Direzione di ricerca

Inizia da tests/test_requests.py:2539 e :2573 in TestTimeout, dove vengono utilizzati gli endpoint delay/10. Modifica i delay in delay/3 e delay/1, mantenendo i timeout e le assertions del client. Esegui i due test di timeout con TestTimeout::test_encoded_methods e conferma che la suite eviti le attese non necessarie del server con gli stessi risultati.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

TestTimeout makes three requests to httpbin("delay/10") and abandons all of them:

  • tests/test_requests.py:2539, test_stream_timeout, timeout=2.0
  • tests/test_requests.py:2573, test_read_timeout, parametrized, timeout=0.1 (two params)

The client raises at 2.0s and 0.1s, but the pytest-httpbin server keeps sleeping the full 10 seconds and serves requests serially. The next test that needs the server blocks until those sleeps finish.

$ pytest "tests/test_requests.py::TestTimeout::test_encoded_methods" -p no:randomly
1 passed in 0.56s

$ pytest "tests/test_requests.py::TestTimeout::test_read_timeout" \
         "tests/test_requests.py::TestTimeout::test_encoded_methods" \
         -p no:randomly --durations=5
19.79s call     tests/test_requests.py::TestTimeout::test_encoded_methods
 0.11s call     tests/test_requests.py::TestTimeout::test_read_timeout[timeout1]
 0.10s call     tests/test_requests.py::TestTimeout::test_read_timeout[timeout0]
3 passed in 20.55s

test_encoded_methods is one line (requests.request(b"GET", httpbin("get"))). The 19.79s is 2 x 10s of server sleep minus the 0.2s the two clients used. In a full run the cost lands on whichever tests happen to follow:

19.35s call     TestTimeout::test_encoded_methods
 8.00s call     TestTimeout::test_none_timeout[None]

Both call sites need the server to outlast the client timeout, not to sleep for 10 seconds. Lowering the delays leaves the assertions unchanged:

  • line 2539, delay/10 to delay/3 (client timeout 2.0)
  • line 2573, delay/10 to delay/1 (client timeout 0.1)

With that change, TestTimeout goes from 30.56s to 5.70s and the full suite from 167.44s to 142.04s, with the same results either way: 630 passed, 3 skipped, 1 xpassed. The single failure in both runs is TestPreparingURLs::test_different_connection_pool_for_tls_settings_verify_bundle_unexpired_cert, which is unrelated and fails before the change as well.

Measured at 611c616 on Windows 11, Python 3.14.2, pytest 9.1.1.

Lingua principale
Python
Stelle
54.6k
Fork
11.5k
Merge medio
18m
PR unite (30g)
1

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di psf/requests

Tutte le issue di psf/requests

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.