From 407352ba14ca6a98a15151ad8b12e9a0e3518217 Mon Sep 17 00:00:00 2001 From: Joseph Martinot-Lagarde Date: Fri, 14 Jun 2019 11:11:24 +0200 Subject: [PATCH 1/2] DOC: Update TESTS.rst.txt for pytest Fully closes #13751. --- doc/TESTS.rst.txt | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/doc/TESTS.rst.txt b/doc/TESTS.rst.txt index 45ff3ec390c7..3a1808ade239 100644 --- a/doc/TESTS.rst.txt +++ b/doc/TESTS.rst.txt @@ -321,11 +321,10 @@ Known failures & skipping tests Sometimes you might want to skip a test or mark it as a known failure, such as when the test suite is being written before the code it's meant to test, or if a test only fails on a particular architecture. -The decorators from numpy.testing.dec can be used to do this. To skip a test, simply use ``skipif``:: - from numpy.testing import dec + import pytest.mark @pytest.mark.skipif(SkipMyTest, reason="Skipping this test because...") def test_something(foo): @@ -334,22 +333,22 @@ To skip a test, simply use ``skipif``:: The test is marked as skipped if ``SkipMyTest`` evaluates to nonzero, and the message in verbose test output is the second argument given to ``skipif``. Similarly, a test can be marked as a known failure by -using ``knownfailureif``:: +using ``xfail``:: from numpy.testing import dec - @dec.knownfailureif(MyTestFails, "This test is known to fail because...") + @pytest.mark.xfail(MyTestFails, reason="This test is known to fail because...") def test_something_else(foo): ... Of course, a test can be unconditionally skipped or marked as a known failure by passing ``True`` as the first argument to ``skipif`` or -``knownfailureif``, respectively. +``xfail``, respectively. A total of the number of skipped and known failing tests is displayed at the end of the test run. Skipped tests are marked as ``'S'`` in the test results (or ``'SKIPPED'`` for ``verbose > 1``), and known -failing tests are marked as ``'K'`` (or ``'KNOWN'`` if ``verbose > +failing tests are marked as ``'x'`` (or ``'XFAIL'`` if ``verbose > 1``). Tests on random data From cd69264f618ae87e638b3fc0420bd5dfb9953f85 Mon Sep 17 00:00:00 2001 From: Joseph Martinot-Lagarde Date: Mon, 17 Jun 2019 10:09:19 +0200 Subject: [PATCH 2/2] Update imports and systematic skip/fail --- doc/TESTS.rst.txt | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/doc/TESTS.rst.txt b/doc/TESTS.rst.txt index 3a1808ade239..14cb28df8cef 100644 --- a/doc/TESTS.rst.txt +++ b/doc/TESTS.rst.txt @@ -324,7 +324,7 @@ meant to test, or if a test only fails on a particular architecture. To skip a test, simply use ``skipif``:: - import pytest.mark + import pytest @pytest.mark.skipif(SkipMyTest, reason="Skipping this test because...") def test_something(foo): @@ -335,15 +335,14 @@ and the message in verbose test output is the second argument given to ``skipif``. Similarly, a test can be marked as a known failure by using ``xfail``:: - from numpy.testing import dec + import pytest @pytest.mark.xfail(MyTestFails, reason="This test is known to fail because...") def test_something_else(foo): ... Of course, a test can be unconditionally skipped or marked as a known -failure by passing ``True`` as the first argument to ``skipif`` or -``xfail``, respectively. +failure by using ``skip`` or ``xfail`` without argument, respectively. A total of the number of skipped and known failing tests is displayed at the end of the test run. Skipped tests are marked as ``'S'`` in