python / python/cpython

python 3.12.5 source install make test test_smtplib FAIL test_with_statement AND test_with_statement_QUIT_failure Connection unexpectedly closed

Abierto
#122,874 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

tests topic-email type-bug
Lenguaje dominante
Python
Estrellas
77.2k
Forks
36k
Métricas de merge de PR
Métricas de PR pendientes

Descripción

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

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Línea de trabajo

Empieza en Lib/test/test_smtplib.py, en SMTPSimTests.test_with_statement y test_with_statement_QUIT_failure, comparando su construcción de SMTP con test_quit_resets_greeting. Ejecuta esas pruebas o make test después de comprobar el argumento localhost propuesto; se considera terminado cuando ambos fallos indicados pasan en Python 3.12.5.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
python
Área
testing-qa
Tipo de issue
Error
Dificultad
2/5
Tiempo estimado
1-3 horas
Estado de actividad
Estancado
Claridad
Bien especificado
Aptitud para principiantes
58/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.