facebook / facebook/TestSlide

Fix TestCase loading with nested classes

Offen
#51 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
bug help wanted Python Unittest
Vorherrschende Sprache
Python
Sterne
149
Forks
62
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

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).

Beitragsleitfaden

Beitragsleitfaden öffnen

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.