Merge remote-tracking branch 'upstream/master' into merge-master-into-features

This commit is contained in:
Bruno Oliveira
2018-04-11 18:07:47 -03:00
57 changed files with 108 additions and 127 deletions

View File

@@ -1,3 +1,4 @@
from _pytest.outcomes import Failed
import pytest
import sys
@@ -61,6 +62,11 @@ class TestRaises(object):
with pytest.raises(TypeError):
pytest.raises('wrong', lambda: None)
def test_invalid_arguments_to_raises(self):
with pytest.raises(TypeError, match='unknown'):
with pytest.raises(TypeError, unknown='bogus'):
raise ValueError()
def test_tuple(self):
with pytest.raises((KeyError, ValueError)):
raise KeyError('oops')
@@ -142,3 +148,20 @@ class TestRaises(object):
with pytest.raises(ValueError):
with pytest.raises(IndexError, match='nomatch'):
int('asdf')
def test_raises_exception_looks_iterable(self):
from six import add_metaclass
class Meta(type(object)):
def __getitem__(self, item):
return 1/0
def __len__(self):
return 1
@add_metaclass(Meta)
class ClassLooksIterableException(Exception):
pass
with pytest.raises(Failed, match="DID NOT RAISE <class 'raises.ClassLooksIterableException'>"):
pytest.raises(ClassLooksIterableException, lambda: None)