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).
This commit is contained in:
Kostis Anagnostopoulos 2020-07-20 15:12:48 +03:00 committed by GitHub
parent efcba7759e
commit 07ed197247
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 13 additions and 2 deletions

View File

@ -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