From 657976e98acc80a0eb44c519f25d89964dba8e10 Mon Sep 17 00:00:00 2001 From: Joan Massich Date: Tue, 22 Aug 2017 12:12:48 +0200 Subject: [PATCH 1/3] update raises documentation regarding regex match --- doc/en/assert.rst | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/doc/en/assert.rst b/doc/en/assert.rst index 406be7e9e..a8ddaecd8 100644 --- a/doc/en/assert.rst +++ b/doc/en/assert.rst @@ -119,9 +119,9 @@ exceptions your own code is deliberately raising, whereas using like documenting unfixed bugs (where the test describes what "should" happen) or bugs in dependencies. -If you want to test that a regular expression matches on the string -representation of an exception (like the ``TestCase.assertRaisesRegexp`` method -from ``unittest``) you can use the ``ExceptionInfo.match`` method:: +Also, the context manager form accepts a ``match`` keyword parameter to test +that a regular expression matches on the string representation of an exception +(like the ``TestCase.assertRaisesRegexp`` method from ``unittest``):: import pytest @@ -129,12 +129,11 @@ from ``unittest``) you can use the ``ExceptionInfo.match`` method:: raise ValueError("Exception 123 raised") def test_match(): - with pytest.raises(ValueError) as excinfo: + with pytest.raises(ValueError, match=r'.* 123 .*'): myfunc() - excinfo.match(r'.* 123 .*') The regexp parameter of the ``match`` method is matched with the ``re.search`` -function. So in the above example ``excinfo.match('123')`` would have worked as +function. So in the above example ``match='123'`` would have worked as well. From 1c891d7d974f2e0b254a950afb10a6f4edd78233 Mon Sep 17 00:00:00 2001 From: Joe Talbott Date: Fri, 25 Aug 2017 10:01:24 -0400 Subject: [PATCH 2/3] Fix typo in goodpractices.rst --- doc/en/goodpractices.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/en/goodpractices.rst b/doc/en/goodpractices.rst index d92e67e02..16fdd24c3 100644 --- a/doc/en/goodpractices.rst +++ b/doc/en/goodpractices.rst @@ -122,7 +122,7 @@ want to distribute them along with your application:: test_view.py ... -In this scheme, it is easy to your run tests using the ``--pyargs`` option:: +In this scheme, it is easy to run your tests using the ``--pyargs`` option:: pytest --pyargs mypkg From 67161ee9f8d1188401ff84c7522785326155d4af Mon Sep 17 00:00:00 2001 From: Joe Talbott Date: Fri, 25 Aug 2017 10:06:45 -0400 Subject: [PATCH 3/3] Add changelog item for PR #2721. --- changelog/2721.trivial | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog/2721.trivial diff --git a/changelog/2721.trivial b/changelog/2721.trivial new file mode 100644 index 000000000..21c9e09e4 --- /dev/null +++ b/changelog/2721.trivial @@ -0,0 +1 @@ +Fixed typo in goodpractices.rst.