From 07ed197247bba6bf9e5f5b4323c08a26a6842880 Mon Sep 17 00:00:00 2001 From: Kostis Anagnostopoulos Date: Mon, 20 Jul 2020 15:12:48 +0300 Subject: [PATCH] doc: note about mutation of parametrized values (#7516) Fix #7514 by augmenting Note with behaviour when parametrized values are mutated (changes are reflected in subsequent test-case calls). --- doc/en/parametrize.rst | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/doc/en/parametrize.rst b/doc/en/parametrize.rst index c8b0bf4f3..9e531ddd4 100644 --- a/doc/en/parametrize.rst +++ b/doc/en/parametrize.rst @@ -79,11 +79,21 @@ them in turn: FAILED test_expectation.py::test_eval[6*9-42] - AssertionError: assert 54... ======================= 1 failed, 2 passed in 0.12s ======================== +.. note:: + + Parameter values are passed as-is to tests (no copy whatsoever). + + For example, if you pass a list or a dict as a parameter value, and + the test case code mutates it, the mutations will be reflected in subsequent + test case calls. + .. note:: pytest by default escapes any non-ascii characters used in unicode strings for the parametrization because it has several downsides. - If however you would like to use unicode strings in parametrization and see them in the terminal as is (non-escaped), use this option in your ``pytest.ini``: + If however you would like to use unicode strings in parametrization + and see them in the terminal as is (non-escaped), use this option + in your ``pytest.ini``: .. code-block:: ini @@ -91,7 +101,8 @@ them in turn: disable_test_id_escaping_and_forfeit_all_rights_to_community_support = True Keep in mind however that this might cause unwanted side effects and - even bugs depending on the OS used and plugins currently installed, so use it at your own risk. + even bugs depending on the OS used and plugins currently installed, + so use it at your own risk. As designed in this example, only one pair of input/output values fails