python 3.12.5 source install make test test_smtplib FAIL test_with_statement AND test_with_statement_QUIT_failure Connection unexpectedly closed
Ninguém assumiu esta issue ainda.
- Linguagem predominante
- Python
- Estrelas
- 77.2k
- Forks
- 36k
- Métricas de merge de PRs
- Métricas de PR pendentes
Descrição
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
Guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Direção de pesquisa
Comece em Lib/test/test_smtplib.py, em SMTPSimTests.test_with_statement e test_with_statement_QUIT_failure, comparando a construção de SMTP deles com test_quit_resets_greeting. Execute esses testes ou make test depois de verificar o argumento localhost proposto; considera-se concluído quando ambas as falhas relatadas passam no Python 3.12.5.
Escrita pelo modelo de indexação a partir do texto da issue.
Avaliação
- Stack de tecnologia
- python
- Domínio
- testing-qa
- Tipo de issue
- Bug
- Dificuldade
- 2/5
- Tempo estimado
- 1-3 horas
- Status de atividade
- Estagnada
- Clareza
- Claramente especificada
- Facilidade para iniciantes
- 58/100