python 3.12.5 source install make test test_smtplib FAIL test_with_statement AND test_with_statement_QUIT_failure Connection unexpectedly closed
Nessuno ha ancora preso questa issue.
- Lingua principale
- Python
- Stelle
- 77.2k
- Fork
- 35.9k
- Metriche di merge delle PR
- Metriche PR in attesa
Descrizione
Bug report
Bug description:
Update: This describes the problem, analysis and suggested fix. Can someone modify the source test code as indicated?
Rocky 9 LINUX
make test
ERROR
======================================================================
ERROR: test_with_statement (test.test_smtplib.SMTPSimTests.test_with_statement)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/defuser/Downloads/Python-3.12.5/Lib/test/test_smtplib.py", line 1231, in test_with_statement
code, message = smtp.noop()
^^^^^^^^^^^
...
======================================================================
ERROR: test_with_statement_QUIT_failure (test.test_smtplib.SMTPSimTests.test_with_statement_QUIT_failure)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/defuser/Downloads/Python-3.12.5/Lib/test/test_smtplib.py", line 1241, in test_with_statement_QUIT_failure
smtp.noop()
cd /home/defuser/Downloads/Python-3.12.5/Lib/test
vi test_smtplib.py
search for (one is right before the other)
test_with_statement
test_with_statement_QUIT_failure
note
with smtplib.SMTP(HOST, self.port, 'localhost') as smtp:
python with explanation, see https://www.geeksforgeeks.org/with-statement-in-python/
IN ANOTHER TERMINAL
cd ~/Downloads/Python-3.12.5
find . -name "smtplib*"
./Doc/library/smtplib.rst
./Lib/smtplib.py
./Lib/__pycache__/smtplib.cpython-312.pyc
view ./Lib/smtplib.py
search for
class SMTP
note this class meets "with" requirements in https://www.geeksforgeeks.org/with-statement-in-python/
def __init__(self, host='', port=0, local_hostname=None,
timeout=socket._GLOBAL_DEFAULT_TIMEOUT,
source_address=None):
RETURN to TERMINAL "vi test_smtplib.py"
SMTP class instantiations (see test_quit_resets_greeting) use
smtp = smtplib.SMTP(HOST, self.port,
local_hostname='localhost' ...)
It is PROBABLY improper to use 'local_hostname=None' in "with" statement.
SOLUTION
In methods test_with_statement and test_with_statement_QUIT_failure
change
with smtplib.SMTP(HOST, self.port) as smtp:
to
with smtplib.SMTP(HOST, self.port, 'localhost') as smtp:
make test will now work
CPython versions tested on:
3.12
Operating systems tested on:
Linux
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia in Lib/test/test_smtplib.py, nei test SMTPSimTests.test_with_statement e test_with_statement_QUIT_failure, confrontando la loro costruzione SMTP con test_quit_resets_greeting. Esegui questi test o make test dopo aver verificato l’argomento localhost proposto; il lavoro è completato quando entrambi i fallimenti segnalati hanno esito positivo su Python 3.12.5.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- python
- Ambito
- testing-qa
- Tipo di issue
- Bug
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Stato di attività
- Ferma
- Chiarezza
- Specificata chiaramente
- Idoneità per principianti
- 58/100