diff options
author | Bruno Oliveira <nicoddemus@gmail.com> | 2018-04-11 18:07:47 -0300 |
---|---|---|
committer | Bruno Oliveira <nicoddemus@gmail.com> | 2018-04-11 18:07:47 -0300 |
commit | 10a71605498d50851e937837fafe2d2672ea2bd4 (patch) | |
tree | d7568cc6bdf500f92bc15e02fa167dcbb21a7b55 /testing | |
parent | 372bcdba0c9a9f84ad9aaec121e0d945a7785013 (diff) | |
parent | e012dbe346d724d91993068c6f5cb15423bb167e (diff) | |
download | pytest-10a71605498d50851e937837fafe2d2672ea2bd4.tar.gz |
Merge remote-tracking branch 'upstream/master' into merge-master-into-features
Diffstat (limited to 'testing')
-rw-r--r-- | testing/python/raises.py | 23 | ||||
-rw-r--r-- | testing/test_junitxml.py | 6 | ||||
-rw-r--r-- | testing/test_recwarn.py | 2 |
3 files changed, 25 insertions, 6 deletions
diff --git a/testing/python/raises.py b/testing/python/raises.py index 183259f6b..053426395 100644 --- a/testing/python/raises.py +++ b/testing/python/raises.py @@ -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) diff --git a/testing/test_junitxml.py b/testing/test_junitxml.py index b8bbd888f..a8f5b9fec 100644 --- a/testing/test_junitxml.py +++ b/testing/test_junitxml.py @@ -868,17 +868,13 @@ def test_record_property(testdir): def test_record(record_property, other): record_property("foo", "<1"); """) - result, dom = runandparse(testdir, '-rw') + result, dom = runandparse(testdir, '-rwv') node = dom.find_first_by_tag("testsuite") tnode = node.find_first_by_tag("testcase") psnode = tnode.find_first_by_tag('properties') pnodes = psnode.find_by_tag('property') pnodes[0].assert_attr(name="bar", value="1") pnodes[1].assert_attr(name="foo", value="<1") - result.stdout.fnmatch_lines([ - 'test_record_property.py::test_record', - '*record_property*experimental*', - ]) def test_record_property_same_name(testdir): diff --git a/testing/test_recwarn.py b/testing/test_recwarn.py index f1cf542e9..1d99a7656 100644 --- a/testing/test_recwarn.py +++ b/testing/test_recwarn.py @@ -113,7 +113,7 @@ class TestDeprecatedCall(object): pass msg = 'Did not produce DeprecationWarning or PendingDeprecationWarning' - with pytest.raises(AssertionError, matches=msg): + with pytest.raises(AssertionError, match=msg): if mode == 'call': pytest.deprecated_call(f) else: |