From 0cd74dc3243877dcb5e0d266e6a1e9862c60f207 Mon Sep 17 00:00:00 2001 From: Tim Strazny Date: Fri, 6 Apr 2018 14:40:30 +0200 Subject: [PATCH] Ensure object is class before calling issubclass. --- _pytest/python_api.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_pytest/python_api.py b/_pytest/python_api.py index 1d1617d72..92eaa5bd5 100644 --- a/_pytest/python_api.py +++ b/_pytest/python_api.py @@ -584,7 +584,7 @@ def raises(expected_exception, *args, **kwargs): """ __tracebackhide__ = True - if not issubclass(expected_exception, BaseException): + if not isclass(expected_exception) or not issubclass(expected_exception, BaseException): for exc in filterfalse(isclass, always_iterable(expected_exception)): msg = ("exceptions must be old-style classes or" " derived from BaseException, not %s")