From 04079f9ae592cf5c8e672f28842ea27c8574c453 Mon Sep 17 00:00:00 2001 From: Raphael Pierzina Date: Wed, 4 Nov 2015 14:49:02 +0100 Subject: [PATCH 1/4] Start doc section on ``--ignore`` in pytestcollection.rst --- doc/en/example/pythoncollection.rst | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/doc/en/example/pythoncollection.rst b/doc/en/example/pythoncollection.rst index 423112af7..dc2ad3623 100644 --- a/doc/en/example/pythoncollection.rst +++ b/doc/en/example/pythoncollection.rst @@ -1,6 +1,13 @@ Changing standard (Python) test discovery =============================================== +Ignore paths during test collection +----------------------------------- + +You can easily ignore certain test directories and modules during collection +by passing the ``--ignore=path`` option on the cli. ``pytest`` allows multiple +``--ignore`` options. + Changing directory recursion ----------------------------------------------------- From 586fdbcbbd4a9b39238c44c9e2f2738280ddd3fb Mon Sep 17 00:00:00 2001 From: Raphael Pierzina Date: Wed, 4 Nov 2015 15:00:37 +0100 Subject: [PATCH 2/4] Add example tests directory structure --- doc/en/example/pythoncollection.rst | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/doc/en/example/pythoncollection.rst b/doc/en/example/pythoncollection.rst index dc2ad3623..eafd4c951 100644 --- a/doc/en/example/pythoncollection.rst +++ b/doc/en/example/pythoncollection.rst @@ -6,7 +6,23 @@ Ignore paths during test collection You can easily ignore certain test directories and modules during collection by passing the ``--ignore=path`` option on the cli. ``pytest`` allows multiple -``--ignore`` options. +``--ignore`` options. Example:: + + tests/ + ├── example + │   ├── test_example_01.py + │   ├── test_example_02.py + │   └── test_example_03.py + ├── foobar + │   ├── test_foobar_01.py + │   ├── test_foobar_02.py + │   └── test_foobar_03.py + └── hello + └── world + ├── test_world_01.py + ├── test_world_02.py + └── test_world_03.py + Changing directory recursion ----------------------------------------------------- From a2d07bfa93fee980e18820f4729dc21a3f4c67cd Mon Sep 17 00:00:00 2001 From: Raphael Pierzina Date: Wed, 4 Nov 2015 15:30:11 +0100 Subject: [PATCH 3/4] Add pytest invocation along with result --- doc/en/example/pythoncollection.rst | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/doc/en/example/pythoncollection.rst b/doc/en/example/pythoncollection.rst index eafd4c951..c4ae3a780 100644 --- a/doc/en/example/pythoncollection.rst +++ b/doc/en/example/pythoncollection.rst @@ -23,6 +23,22 @@ by passing the ``--ignore=path`` option on the cli. ``pytest`` allows multiple ├── test_world_02.py └── test_world_03.py +Now invoke ``pytest`` with ``--ignore`` to ignore a particular directory and a module as follows:: + + $ py.test tests --ignore=tests/foobar/test_foobar_03.py --ignore=tests/hello/ + ========= test session starts ========== + platform darwin -- Python 2.7.10, pytest-2.8.2, py-1.4.30, pluggy-0.3.1 + rootdir: $REGENDOC_TMPDIR, inifile: + collected 5 items + + tests/example/test_example_01.py . + tests/example/test_example_02.py . + tests/example/test_example_03.py . + tests/foobar/test_foobar_01.py . + tests/foobar/test_foobar_02.py . + + ======= 5 passed in 0.02 seconds ======= + Changing directory recursion ----------------------------------------------------- From d667259e3133574c2b7f7461d4781b79440e433d Mon Sep 17 00:00:00 2001 From: Raphael Pierzina Date: Wed, 4 Nov 2015 23:45:29 +0100 Subject: [PATCH 4/4] Change pytest ignore invocation as suggested by @nicoddemus --- doc/en/example/pythoncollection.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/en/example/pythoncollection.rst b/doc/en/example/pythoncollection.rst index c4ae3a780..a95b5b624 100644 --- a/doc/en/example/pythoncollection.rst +++ b/doc/en/example/pythoncollection.rst @@ -23,9 +23,9 @@ by passing the ``--ignore=path`` option on the cli. ``pytest`` allows multiple ├── test_world_02.py └── test_world_03.py -Now invoke ``pytest`` with ``--ignore`` to ignore a particular directory and a module as follows:: +Now if you invoke ``pytest`` with ``--ignore=tests/foobar/test_foobar_03.py --ignore=tests/hello/``, +you will see that ``pytest`` only collects test-modules, which do not match the patterns specified:: - $ py.test tests --ignore=tests/foobar/test_foobar_03.py --ignore=tests/hello/ ========= test session starts ========== platform darwin -- Python 2.7.10, pytest-2.8.2, py-1.4.30, pluggy-0.3.1 rootdir: $REGENDOC_TMPDIR, inifile: