When mocking with `unsafe=True` the mocked instances don't receive the unsafe argument.
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- Python
- Estrellas
- 77.2k
- Forks
- 36k
- Merge medio
- 1 d 9 h
- PR fusionados (30 d)
- 558
Descripción
Bug report
When the feature Check against misspellings of assert etc. in mock was introduced, the unsafe flag was moved out from kwargs and defined as a named argument.
Previously since unsafe was implicitly part of kwargs, it was silently propagated from _patch class to the instantiation of the klass variable inside the __enter__ method.
But now, the unsafe flag as an explicitly named argument is not being propagated to the instantiation of the Klass variable.
Hence the Mock class is unable to set its internal attribute _mock_unsafe and will always be False regardless of whether the user set unsafe=True or not.
The test cases have to be updated to show this bug.
This bug was introduced in this commit: fdb9efce6ac211f973088eef508740c3fa2bd182 (bpo-41877) and only included in versions from Python 3.10.
Your environment
- CPython versions tested on: 3.10, 3.11 and master branch.
- Operating system and architecture: Ubuntu 22.04
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 en la clase _patch y su método enter, donde se crea la instancia de Klass, e inspecciona cómo se pasa unsafe a Mock. Actualiza los casos de prueba relevantes para demostrar que unsafe=True llega a las instancias simuladas y que su estado interno unsafe cambia en consecuencia.
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
- Bastante claro
- Aptitud para principiantes
- 45/100