test.test_pdb.PdbTestColorize.test_gen_colors fails when pyrepl is unavailable at runtime
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- Python
- Estrellas
- 77.2k
- Forks
- 35.9k
- Métricas de merge de PR
- Métricas de PR pendientes
Descripción
Bug report
Bug description:
Description
test.test_pdb.PdbTestColorize.test_gen_colors can fail in the standard test suite (for example via make test) with:
Re-running test_pdb in verbose mode (matching: test_gen_colors)
test_gen_colors (test.test_pdb.PdbTestColorize.test_gen_colors) ... ERROR
======================================================================
ERROR: test_gen_colors (test.test_pdb.PdbTestColorize.test_gen_colors)
----------------------------------------------------------------------
Traceback (most recent call last):
File [35m"/home/yansendao/git/cpython-ysd/Lib/test/test_pdb.py"[0m, line [35m5008[0m, in [35mtest_gen_colors[0m
gen_colors = [1;31mp.pyrepl_input.gen_colors[0m
[1;31m^^^^^^^^^^^^^^^^^^^^^^^^^[0m
[1;35mAttributeError[0m: [35m'NoneType' object has no attribute 'gen_colors'[0m
Root cause
There are two related problems:
@unittest.skipIf(not pdb._pyrepl_available()) is evaluated at import time
unittest.skipIf checks its condition when the test class is defined, not when the test runs. In regrtest worker subprocesses, sys.stdin may be a TTY at import time but is no longer suitable when the test executes, so the skip condition and runtime behavior diverge.
pdb._pyrepl_available() does not match Pdb initialization
_pyrepl_available() only consults _pyrepl.main.CAN_USE_PYREPL, which is computed once at import time. Pdb.init may still fail to create PdbPyReplInput (for example when stdin is not a TTY), silently leaving self.pyrepl_input = None.
Additionally, _pyrepl_available() always inspected sys.stdin, while Pdb uses self.stdin and self.stdout.
Steps to reproduce
time ( rm -rf build ; mkdir build ; cd build ; ../configure --prefix=$PWD/install &> configure.log ; make -j &> make.log ; make -j install &> install.log ; time make test TESTPYTHONOPTS="-s" TESTOPTS="-v -
uall,-network,-gui --junit-xml cpython.xml test_pdb" &> test_pdb.log )
CPython versions tested on:
CPython main branch
Operating systems tested on:
Linux
Linked PRs
- gh-150545
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Línea de trabajo
Comienza con test/test_pdb.py, especialmente con PdbTestColorize.test_gen_colors, y sigue su condición de omisión junto con pdb._pyrepl_available() y la inicialización de Pdb. Reproduce el fallo con el comando de prueba indicado y, después, verifica que la comprobación de disponibilidad del test coincide con el comportamiento de Pdb en tiempo de ejecución y que el test pasa cuando pyrepl no está disponible.
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
- 4/5
- Tiempo estimado
- 3-5 días
- Estado de actividad
- Estancado
- Claridad
- Bien especificado
- Aptitud para principiantes
- 35/100