From 97d48ba60d7e0af9a204c2f03807c78d3397440d Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Sat, 9 Jun 2018 11:59:02 -0300 Subject: [PATCH 1/3] Add documentation blurb for --strict Fix #3549 --- changelog/3549.doc.rst | 1 + doc/en/mark.rst | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 changelog/3549.doc.rst diff --git a/changelog/3549.doc.rst b/changelog/3549.doc.rst new file mode 100644 index 000000000..62bc4f9a5 --- /dev/null +++ b/changelog/3549.doc.rst @@ -0,0 +1 @@ +Add documentation for the ``--strict`` flag. diff --git a/doc/en/mark.rst b/doc/en/mark.rst index e48135b10..753bd1c95 100644 --- a/doc/en/mark.rst +++ b/doc/en/mark.rst @@ -26,6 +26,30 @@ which also serve as documentation. :ref:`fixtures `. +Raising errors on unknown marks: --strict +----------------------------------------- + +The ``--strict`` command-line flag can be used to raise errors when marks not registered in the ``pytest.ini`` file. +Marks can be registered like this: + +.. code-block:: ini + + [pytest] + markers = + slow + serial + +This can be used to prevent users mistyping mark names by accident. Test suites that want to enforce that this +should add ``--strict`` to ``addopts``: + +.. code-block:: ini + + [pytest] + addopts = --strict + markers = + slow + serial + .. currentmodule:: _pytest.mark.structures .. autoclass:: Mark :members: From 3667a52ba2b83e0cf07861d01e949ebd33afe7ec Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Sat, 9 Jun 2018 11:59:57 -0300 Subject: [PATCH 2/3] Remove Mark api from mark.rst Feels out of place in there, plus the reference documentation already contains the reference API to all mark-related classes --- doc/en/mark.rst | 5 ----- 1 file changed, 5 deletions(-) diff --git a/doc/en/mark.rst b/doc/en/mark.rst index 753bd1c95..4f4242490 100644 --- a/doc/en/mark.rst +++ b/doc/en/mark.rst @@ -50,11 +50,6 @@ should add ``--strict`` to ``addopts``: slow serial -.. currentmodule:: _pytest.mark.structures -.. autoclass:: Mark - :members: - :noindex: - .. `marker-iteration` From c4f72e4d133e8eec407e7c3f8efaae589ce9e5e0 Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Sat, 9 Jun 2018 12:40:39 -0300 Subject: [PATCH 3/3] Apply code review changes --- doc/en/mark.rst | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/doc/en/mark.rst b/doc/en/mark.rst index 4f4242490..e47b8c3fb 100644 --- a/doc/en/mark.rst +++ b/doc/en/mark.rst @@ -29,7 +29,8 @@ which also serve as documentation. Raising errors on unknown marks: --strict ----------------------------------------- -The ``--strict`` command-line flag can be used to raise errors when marks not registered in the ``pytest.ini`` file. +When the ``--strict`` command-line flag is passed, any marks not registered in the ``pytest.ini`` file will trigger an error. + Marks can be registered like this: .. code-block:: ini @@ -39,7 +40,7 @@ Marks can be registered like this: slow serial -This can be used to prevent users mistyping mark names by accident. Test suites that want to enforce that this +This can be used to prevent users mistyping mark names by accident. Test suites that want to enforce this should add ``--strict`` to ``addopts``: .. code-block:: ini