facebook / facebook/TestSlide

Fix TestCase loading with nested classes

未关闭
#51 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
bug help wanted Python Unittest
主要语言
Python
星标
149
派生
62
PR 合并指标
30 天内没有已合并 PR

描述

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

贡献指南

打开贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。