Merge remote-tracking branch 'upstream/master' into cybergrind/fix_baseexception
This commit is contained in:
commit
f4e811afc0
|
@ -0,0 +1 @@
|
|||
Fixed typo in goodpractices.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.
|
||||
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in New Issue