python: collect: ignore exceptions with isinstance

Fixes https://github.com/pytest-dev/pytest/issues/4266.
This commit is contained in:
Daniel Hahler
2018-11-01 00:54:48 +01:00
parent 56e6bb0ff6
commit e30f7094f3
6 changed files with 74 additions and 1 deletions

View File

@@ -33,6 +33,7 @@ from _pytest.compat import NoneType
from _pytest.compat import NOTSET
from _pytest.compat import REGEX_TYPE
from _pytest.compat import safe_getattr
from _pytest.compat import safe_isclass
from _pytest.compat import safe_str
from _pytest.compat import STRING_TYPES
from _pytest.config import hookimpl
@@ -195,7 +196,7 @@ def pytest_pycollect_makeitem(collector, name, obj):
if res is not None:
return
# nothing was collected elsewhere, let's do it here
if isclass(obj):
if safe_isclass(obj):
if collector.istestclass(obj, name):
Class = collector._getcustomclass("Class")
outcome.force_result(Class(name, parent=collector))