[issue29642] Why does unittest.TestLoader.discover still rely on existence of __init__.py files?
Andrei Fokau
report at bugs.python.org
Fri Feb 24 15:17:00 EST 2017
Andrei Fokau added the comment:
Ok, it's actually not so hard to work around (for Python 3.6, at least):
import os
from unittest import TestLoader
class CustomTestLoader(TestLoader):
def _find_test_path(self, full_path, pattern, namespace=False):
original_isfile = os.path.isfile
def patched_isfile(path):
return str(path).endswith('__init__.py') or original_isfile(path)
os.path.isfile = patched_isfile
result = super()._find_test_path(full_path=full_path, pattern=pattern,
namespace=namespace)
os.path.isfile = original_isfile
return result
I'll try to submit a pull request if it can be resolved properly.
----------
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue29642>
_______________________________________
More information about the Python-bugs-list
mailing list