When using pytest.parametrize with multiline strings, the new line string literal \n causes the test name to change on each test run, which causes unexpected behavior.
Here's an example given the following script script.py:
When running pytest script.py I get 1 snapshots written and 1 snapshots deprecated which returns an invalid python file (notice the malformed second test):
Using pytest parametrize for multiline strings is specifically important when using snapshottest with graphene. There should be countless other use cases besides that.
When using pytest.parametrize with multiline strings, the new line string literal
\n
causes the test name to change on each test run, which causes unexpected behavior.Here's an example given the following script
script.py
:When running
pytest script.py
I get2 snapshots written
which look like this:When running
pytest script.py
I get1 snapshots written
and1 snapshots deprecated
which returns an invalid python file (notice the malformed second test):This fix will return the following snapshots on each test run:
Using pytest parametrize for multiline strings is specifically important when using snapshottest with graphene. There should be countless other use cases besides that.