Closed
Description
Several methods on unittest.TestLoader have a "module" argument. Inspecting the code, its clear that these functions actually operate on modules directly. I believe they've incorrectly been typed str
.
From https://github.com/python/typeshed/blob/master/stdlib/2/unittest.pyi#L195:
class TestLoader:
...
def loadTestsFromModule(self, module: str = ...,
use_load_tests: bool = ...) -> TestSuite: ...
def loadTestsFromName(self, name: str = ...,
module: Optional[str] = ...) -> TestSuite: ...
def loadTestsFromNames(self, names: List[str] = ...,
module: Optional[str] = ...) -> TestSuite: ...
From https://github.com/python/cpython/blob/master/Lib/unittest/loader.py#L121:
def loadTestsFromModule(self, module, *args, pattern=None, **kws):
...
for name in dir(module):
obj = getattr(module, name)
if isinstance(obj, type) and issubclass(obj, case.TestCase):
tests.append(self.loadTestsFromTestCase(obj))
...
Clearly, for name in dir(module)
is not going to yield unittest.TestCase subclasses if module is a str
; the code expects a module object instead. The same is true for loadTestsFromName
and loadTestsFromNames
.
Metadata
Metadata
Assignees
Labels
No labels