Pytest: `disable_test_id_escaping_and_forfeit_all_rights_to_community_support` doesn't work when using list of IDs

Created on 17 May 2019  ยท  5Comments  ยท  Source: pytest-dev/pytest

  • [x] a detailed description of the bug or suggestion
  • [x] output of pip list from the virtual environment you are using
  • [x] pytest and operating system versions
  • [x] minimal example if possible

description

When parametrizing tests applying a list of test IDs, disable_test_id_escaping_and_forfeit_all_rights_to_community_support option doesn't work.
But it works when specifying an ID function.

import pytest

testdata = [True]
ids = ["้žใ‚ขใ‚นใ‚ญใƒผๆ–‡ๅญ—"]
idfn = lambda _: "้žใ‚ขใ‚นใ‚ญใƒผๆ–‡ๅญ—"

# it works
@pytest.mark.parametrize('a', testdata, ids=idfn)
def test_idfn(a):
    assert a

# it doesn't work
@pytest.mark.parametrize('a', testdata, ids=ids)
def test_ids(a):
    assert a

screenshot

The full example code is here: https://github.com/akiomik/pytest-disable_test_id_escaping_option-doesnt-work

environments

  • OS: macOS Mojave 10.14.4
  • pipenv: version 2018.11.26
  • python: 3.7.2
  • pytest: 4.5.0

pip list

Package        Version
-------------- -------
atomicwrites   1.3.0
attrs          19.1.0
more-itertools 7.0.0
pip            19.1.1
pluggy         0.11.0
py             1.8.0
pytest         4.5.0
setuptools     41.0.1
six            1.12.0
wcwidth        0.1.7
wheel          0.33.4

Most helpful comment

sweet! looking forward to your contribution ๐ŸŽ‰

All 5 comments

๐Ÿ˜† I had no idea we had such an option -- though, as it says on the tin:

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.

I suspect if you want this to work you'll need to patch the callsites that use ascii_escaped, though I wonder why we have this option at all ๐Ÿค”

4995 was when this was introduced

Thank you! I know I understand the risk ๐Ÿ˜‰

you'll need to patch the callsites that use ascii_escaped

It works by changing ascii_escaped to _ascii_escaped_by_config at _idvalset in python.py as you said.

At the least, I'd need this option because that improves readability of a test results. ๐Ÿ™

would you like to submit a patch that does that?

Yes!

sweet! looking forward to your contribution ๐ŸŽ‰

Was this page helpful?
0 / 5 - 0 ratings