Assertion diff doesn't pretty-print the built-in frozen dict (Python 3.15)
Los mantenedores suelen responder en 1 día
@HakeemTheEmperor ya está trabajando en esto.
Desde el 13/10/2026.
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 78/100
Línea de trabajo
La corrección debe ir en src/_pytest/_io/pprint.py. Lee PrettyPrinter._dispatch y el manejador existente _pprint_ordered_dict, y luego añade un manejador para frozendict que solo se registre cuando exista el tipo frozendict, para que las versiones antiguas de Python no se vean afectadas. Reproduce el problema con la lista de dos elementos de frozendicts del issue usando pytest -vv. Está terminado cuando el Full diff coloca las claves de cada frozendict en líneas separadas y se marca el valor cambiado de age, y cuando pasa un test que cubre el nuevo manejador.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Python 3.15 added frozendict as a built-in type (PEP 814). When an assertion
comparing frozendicts fails with -vv, the "Full diff" prints each frozendict on
a single line. A dict with the same contents gets one key per line, which makes
the changed value easy to spot. With frozendict the change is buried mid-line.
def test_frozendict():
left = [frozendict(name='alice', age=30, city='Lagos'), frozendict(name='bob', age=25, city='Abuja')]
right = [frozendict(name='alice', age=30, city='Lagos'), frozendict(name='bob', age=26, city='Abuja')]
assert left == right
Output with pytest -vv:
Full diff:
[
frozendict({'name': 'alice', 'age': 30, 'city': 'Lagos'}),
- frozendict({'name': 'bob', 'age': 26, 'city': 'Abuja'}),
? ^
+ frozendict({'name': 'bob', 'age': 25, 'city': 'Abuja'}),
? ^
]
The same test using dict:
Full diff:
[
{
'name': 'alice',
'age': 30,
'city': 'Lagos',
},
{
'name': 'bob',
- 'age': 26,
? ^
+ 'age': 25,
? ^
'city': 'Abuja',
},
]
I think the cause is in src/_pytest/_io/pprint.py. PrettyPrinter._dispatch
has handlers for dict, OrderedDict, defaultdict, MappingProxyType and
others, but not frozendict, so it falls back to a one-line repr(). The
standard library's pprint in 3.15 already supports frozendict.
A possible fix is a _pprint_frozendict handler similar to _pprint_ordered_dict,
registered only when frozendict exists, so older Python versions aren't affected.
Versions
pytest 9.1.1, Python 3.15.0, Windows 11. Also seen on pytest main with Python 3.15 on Linux.
pip list
Package Version
--------- -------
colorama 0.4.6
iniconfig 2.3.1
packaging 26.3
pip 26.2.1
pluggy 1.6.0
Pygments 2.21.0
pytest 9.1.1
I'm happy to open a PR for this.
- Lenguaje dominante
- Python
- Estrellas
- 14.6k
- Forks
- 3.5k
- Merge medio
- 1 d 17 h
- PR fusionados (30 d)
- 25
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la 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.
Más de pytest-dev/pytest
-
Subtest durations become negative when `time` is mocked (subtests.py bypasses `_pytest.timing`)Posiblemente ocupada @RonnyPfannschmidt la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
pytest-dev/pytest#15201 ·
Los mantenedores suelen responder en 1 día
-
`faulthandler_timeout` stops covering a test once setup, call or a subtest fails (`pytest_exception_interact` cancels the timer)Posiblemente ocupada @XXXXXQ-0206 la tomó hace 3 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
pytest-dev/pytest#15180 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
monkeypatch.setattr fails to undo on objects with a custom __setattr__ (regression from #14969)Posiblemente ocupada @hardikkaurani la tomó hace 24 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
pytest-dev/pytest#15099 · 6 comentarios ·
Los mantenedores suelen responder en 1 día
-
Allow dotted test filenames (`*.test.py`) via one-line change to `compute_module_name`Quizá libre de nuevo @siddy-stack la tomó hace 62 días y no hay ningún pull request abierto. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 86/100
pytest-dev/pytest#14514 · 6 comentarios ·
Los mantenedores suelen responder en 1 día
-
Expose CaptureManager as public APIQuizá libre de nuevo @harsh21234i la tomó hace 200 días y no hay ningún pull request abierto. Abiertotype: enhancement type: feature-branch
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
pytest-dev/pytest#14186 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
Todos los issues de pytest-dev/pytest
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 83/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 86/100
google-ai-edge/litert-torch#1346 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
geneontology/gocam-py#272 ·
-
pushed_authorization_request sends list authorization_details as a Python reprPosiblemente ocupada @RaphaelFakhri la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
auth0/auth0-python#903 ·
Los mantenedores suelen responder en 1 día