Skip to content

Commit 07ed197

Browse files
authored
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).
1 parent efcba77 commit 07ed197

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

doc/en/parametrize.rst

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,19 +79,30 @@ them in turn:
7979
FAILED test_expectation.py::test_eval[6*9-42] - AssertionError: assert 54...
8080
======================= 1 failed, 2 passed in 0.12s ========================
8181
82+
.. note::
83+
84+
Parameter values are passed as-is to tests (no copy whatsoever).
85+
86+
For example, if you pass a list or a dict as a parameter value, and
87+
the test case code mutates it, the mutations will be reflected in subsequent
88+
test case calls.
89+
8290
.. note::
8391

8492
pytest by default escapes any non-ascii characters used in unicode strings
8593
for the parametrization because it has several downsides.
86-
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``:
94+
If however you would like to use unicode strings in parametrization
95+
and see them in the terminal as is (non-escaped), use this option
96+
in your ``pytest.ini``:
8797

8898
.. code-block:: ini
8999
90100
[pytest]
91101
disable_test_id_escaping_and_forfeit_all_rights_to_community_support = True
92102
93103
Keep in mind however that this might cause unwanted side effects and
94-
even bugs depending on the OS used and plugins currently installed, so use it at your own risk.
104+
even bugs depending on the OS used and plugins currently installed,
105+
so use it at your own risk.
95106

96107

97108
As designed in this example, only one pair of input/output values fails

0 commit comments

Comments
 (0)