Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add ini option to disable string escape for parametrization #2537

Closed

Conversation

ApaDoctor
Copy link
Contributor

solving #2482

@@ -909,7 +912,11 @@ def _idval(val, argname, idx, idfn, config=None):
return hook_id

if isinstance(val, STRING_TYPES):
return _escape_strings(val)
if config is None:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for sanity and adding a unittest please extract this to a own function

escape_option = False
else:
escape_option = config.getini("disable_test_id_escaping_and_forfeit_all_rights_to_community_support")
return val if escape_option else _escape_strings(val)
elif isinstance(val, (float, int, bool, NoneType)):
return str(val)
elif isinstance(val, REGEX_TYPE):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wrt regex its not clear if we should or should not escape

@coveralls
Copy link

Coverage Status

Coverage increased (+0.003%) to 92.157% when pulling de6eb4c on ApaDoctor:disable-escape-test-id into 9b51fc6 on pytest-dev:features.

@RonnyPfannschmidt
Copy link
Member

your re-factoring tool made a mess of the white space bu im inclined to still accept the changes as they make stuff better 👍

@nicoddemus can we merge master timely to sort out merge issues?

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.01%) to 92.143% when pulling 7073b36 on ApaDoctor:disable-escape-test-id into 9b51fc6 on pytest-dev:features.

@nicoddemus
Copy link
Member

@ApaDoctor sorry I hate to ask this, but could you remake the patch without all the whitespace/formatting changes? I'm sure you can disable that in your editor. Unfortunately as it stands the patch makes a mess of the history because we lose the authors of the changed lines.

@RonnyPfannschmidt definitely about merging this with master asap, but I really would rather not having the whitespace changes in place.

Copy link
Member

@nicoddemus nicoddemus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove unintentional whitespace changes.

@ApaDoctor
Copy link
Contributor Author

Sorry for the long pause. I'll fix whitespace problem in closest time

@nicoddemus
Copy link
Member

No problem, thanks for the follow up

@ApaDoctor
Copy link
Contributor Author

So i completed all changes. PR can be approved

@@ -910,6 +914,14 @@ def _find_parametrized_scope(argnames, arg2fixturedefs, indirect):
return 'function'


def _escape_strings_checker(val, config=None):
if config is None:
escape_option = False
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe call this disable_escaping to make it more clear.


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 them, use the option disable_test_id_escaping_and_forfeit_all_rights_to_community_support = False
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

= True?

@coveralls
Copy link

Coverage Status

Coverage increased (+30.1%) to 92.51% when pulling b6bff74 on ApaDoctor:disable-escape-test-id into de0d19c on pytest-dev:features.

@coveralls
Copy link

Coverage Status

Coverage increased (+30.1%) to 92.51% when pulling fac2b16 on ApaDoctor:disable-escape-test-id into de0d19c on pytest-dev:features.

@coveralls
Copy link

Coverage Status

Coverage increased (+30.1%) to 92.51% when pulling d432553 on ApaDoctor:disable-escape-test-id into de0d19c on pytest-dev:features.

Copy link
Member

@nicoddemus nicoddemus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @ApaDoctor for the follow up, we appreciate it!

Some final requests before we merge:

  1. Please add a changelog entry for this, I suggest 2482.feature with this contents:
Include new ``disable_test_id_escaping_and_forfeit_all_rights_to_community_support`` option to disable ascii-escaping in parametrized values. This may cause a series of problems and as the name makes clear, use at your own risk.
  1. Can you please rebase all your commits in a single commit?


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 them, use the option disable_test_id_escaping_and_forfeit_all_rights_to_community_support = True
Copy link
Member

@nicoddemus nicoddemus Sep 26, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small nit:

If however you would like to use unicode strings in parametrization, use this option in your ``pytest.ini``:

.. code-block:: ini

    [pytest]
    disable_test_id_escaping_and_forfeit_all_rights_to_community_support = True


parser.addini("disable_test_id_escaping_and_forfeit_all_rights_to_community_support", type="bool",
default=False, help="disable string escape non-ascii"
" characters, might cause unwanted side effects")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it worth adding a "(use at your own risk)" here.

@dnnr
Copy link

dnnr commented Jan 3, 2019

@ApaDoctor @nicoddemus What ever happened to this? It sounded ready to go, then it just got closed?

@nicoddemus
Copy link
Member

Not sure, @ApaDoctor simply closed this, I assumed he wanted to withdraw his contribution... 😕

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants