Skip to content

Commit

Permalink
Merge pull request #3265 from pytest-dev/feature/always-iterable-refa…
Browse files Browse the repository at this point in the history
…ctor

Consolidate behavior by using filterfalse and always_iterable
  • Loading branch information
RonnyPfannschmidt committed Mar 1, 2018
2 parents 9fcbf57 + 14a9b1e commit 3b757b1
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
15 changes: 6 additions & 9 deletions _pytest/python_api.py
Expand Up @@ -2,7 +2,8 @@
import sys

import py
from six.moves import zip
from six.moves import zip, filterfalse
from more_itertools.more import always_iterable

from _pytest.compat import isclass
from _pytest.outcomes import fail
Expand Down Expand Up @@ -566,14 +567,10 @@ def raises(expected_exception, *args, **kwargs):
"""
__tracebackhide__ = True
msg = ("exceptions must be old-style classes or"
" derived from BaseException, not %s")
if isinstance(expected_exception, tuple):
for exc in expected_exception:
if not isclass(exc):
raise TypeError(msg % type(exc))
elif not isclass(expected_exception):
raise TypeError(msg % type(expected_exception))
for exc in filterfalse(isclass, always_iterable(expected_exception)):
msg = ("exceptions must be old-style classes or"
" derived from BaseException, not %s")
raise TypeError(msg % type(exc))

message = "DID NOT RAISE {0}".format(expected_exception)
match_expr = None
Expand Down
1 change: 1 addition & 0 deletions changelog/3265.trivial.rst
@@ -0,0 +1 @@
``pytest`` now depends on the `more_itertools <https://github.com/erikrose/more-itertools>`_ package.
1 change: 1 addition & 0 deletions setup.py
Expand Up @@ -60,6 +60,7 @@ def main():
'six>=1.10.0',
'setuptools',
'attrs>=17.2.0',
'more_itertools>=4.0.0',
]
# if _PYTEST_SETUP_SKIP_PLUGGY_DEP is set, skip installing pluggy;
# used by tox.ini to test with pluggy master
Expand Down

0 comments on commit 3b757b1

Please sign in to comment.