facebook / facebook/TestSlide

Fix TestCase loading with nested classes

Abierto
#51 0 comentarios 0 reacciones 0 asignados Ver en GitHub
bug help wanted Python Unittest
Lenguaje dominante
Python
Estrellas
149
Forks
62
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

TestSlide loads TestCase classes using [this logic](https://github.com/facebookincubator/TestSlide/blob/b2d2ef9c288082b476332938bfc1d486abb0137e/testslide/cli.py#L59-L63). Upstream Python, does it [like this](https://github.com/python/cpython/blob/fd628cf5adaeee73eab579393cdff71c8f70cdf2/Lib/unittest/loader.py#L121-L124). This means, that If the module has this:

```python
class Outer:
class Inner(TestCase):
def test_something(self):
pass
```

Python won't consider `Inner.test_something` as part of the test, but TestSlide will.

This can be easily fixed by refactoring the logic at TestSlide's side to match Python's, however, it won't cover other cases such as [`load_tests()`](https://github.com/python/cpython/blob/fd628cf5adaeee73eab579393cdff71c8f70cdf2/Lib/unittest/loader.py#L126-L130).

The proper fix for this, is to use Python's [`TestLoader`](https://github.com/python/cpython/blob/fd628cf5adaeee73eab579393cdff71c8f70cdf2/Lib/unittest/loader.py#L66) in the same fashion as Python unittent [does form its CLI](https://github.com/python/cpython/blob/fd628cf5adaeee73eab579393cdff71c8f70cdf2/Lib/unittest/main.py#L156).

Guía de contribución

Abrir la guía de contribución

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.