From c90e76c371c20ef27655334274add16fe3d34baf Mon Sep 17 00:00:00 2001 From: Austin Date: Sat, 16 Dec 2017 08:25:02 -0600 Subject: [PATCH 1/4] Clarifiyng documentation for parameterize - Added snippet dealing with parameterize run order of tests --- doc/en/parametrize.rst | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/doc/en/parametrize.rst b/doc/en/parametrize.rst index 7a4ac2e18..b1d62d486 100644 --- a/doc/en/parametrize.rst +++ b/doc/en/parametrize.rst @@ -126,6 +126,22 @@ To get all combinations of multiple parametrized arguments you can stack This will run the test with the arguments set to ``x=0/y=2``, ``x=0/y=3``, ``x=1/y=2`` and ``x=1/y=3``. +Due to how decorators work it runs in reverse of expected order. +In this case:: + + $ pytest + =========================== test session starts ============================ + platform linux -- Python 3.x.y, pytest-3.x.y, py-1.x.y, pluggy-0.x.y + rootdir: $REGENDOC_TMPDIR, inifile: + collected 4 items + + test.py::test_foo[2-0] PASSED [ 25%] + test.py::test_foo[2-1] PASSED [ 50%] + test.py::test_foo[3-0] PASSED [ 75%] + test.py::test_foo[3-1] PASSED [100%] + + ========================== 4 passed in 0.01 seconds ======================== + .. _`pytest_generate_tests`: Basic ``pytest_generate_tests`` example From d7a76a4d07c9dc778c3d1ab6bbb783f8b95da719 Mon Sep 17 00:00:00 2001 From: Austin Date: Sat, 16 Dec 2017 09:04:18 -0600 Subject: [PATCH 2/4] Updated for more clarity - Changed original wording for parameterize. Should help be a little more clear --- doc/en/parametrize.rst | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/doc/en/parametrize.rst b/doc/en/parametrize.rst index b1d62d486..310e05d21 100644 --- a/doc/en/parametrize.rst +++ b/doc/en/parametrize.rst @@ -126,21 +126,9 @@ To get all combinations of multiple parametrized arguments you can stack This will run the test with the arguments set to ``x=0/y=2``, ``x=0/y=3``, ``x=1/y=2`` and ``x=1/y=3``. -Due to how decorators work it runs in reverse of expected order. -In this case:: - - $ pytest - =========================== test session starts ============================ - platform linux -- Python 3.x.y, pytest-3.x.y, py-1.x.y, pluggy-0.x.y - rootdir: $REGENDOC_TMPDIR, inifile: - collected 4 items - - test.py::test_foo[2-0] PASSED [ 25%] - test.py::test_foo[2-1] PASSED [ 50%] - test.py::test_foo[3-0] PASSED [ 75%] - test.py::test_foo[3-1] PASSED [100%] - - ========================== 4 passed in 0.01 seconds ======================== +Note that due to how decorators work in python the tests actually exhaust parameters in +the order of the decorators. For example this program run in the order ``x=0/y=2``, +``x=1/y=2``, ``x=0/y=3``, and ``x=1/y=3``. .. _`pytest_generate_tests`: From 73eccb4c3676ca70bff9e69394dfd425d286ff65 Mon Sep 17 00:00:00 2001 From: Austin Date: Sat, 16 Dec 2017 09:21:27 -0600 Subject: [PATCH 3/4] Adding news fragment --- changelog/3001.doc | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog/3001.doc diff --git a/changelog/3001.doc b/changelog/3001.doc new file mode 100644 index 000000000..e9b4dbd52 --- /dev/null +++ b/changelog/3001.doc @@ -0,0 +1 @@ +Add clarifying note about behavior of multiple parametrized arguments From 70461d1eada70c24a4a511bf09ae670d22e899c8 Mon Sep 17 00:00:00 2001 From: Austin Date: Sat, 16 Dec 2017 09:31:48 -0600 Subject: [PATCH 4/4] Update parametrize.rst --- doc/en/parametrize.rst | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/doc/en/parametrize.rst b/doc/en/parametrize.rst index 310e05d21..7bc37ae38 100644 --- a/doc/en/parametrize.rst +++ b/doc/en/parametrize.rst @@ -123,12 +123,8 @@ To get all combinations of multiple parametrized arguments you can stack def test_foo(x, y): pass -This will run the test with the arguments set to ``x=0/y=2``, ``x=0/y=3``, ``x=1/y=2`` and -``x=1/y=3``. - -Note that due to how decorators work in python the tests actually exhaust parameters in -the order of the decorators. For example this program run in the order ``x=0/y=2``, -``x=1/y=2``, ``x=0/y=3``, and ``x=1/y=3``. +This will run the test with the arguments set to ``x=0/y=2``,``x=1/y=2``, +``x=0/y=3``, and ``x=1/y=3`` exhausting parameters in the order of the decorators. .. _`pytest_generate_tests`: