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

Escape both bytes and unicode strings for "ids" in Metafunc.parametrize #1470

Merged
merged 7 commits into from
Apr 3, 2016
Merged

Conversation

ceridwen
Copy link
Contributor

This is the new version of #1463 based on the features branch.

@nicoddemus
Copy link
Member

@ceridwen could you please solve the conflict? Sorry about that, it must have been another merge that happened earlier.

@ceridwen
Copy link
Contributor Author

I solved the conflict. I haven't changed the tests yet. Is my proposed resolution acceptable? I'm planning to repurpose test_unicode_idval_python to check for escaping.

Should I change any of the other nearby tests to check for escaping? Should I write a Hypothesis test for this code? I'm willing to use my own judgment here, but I don't want to trip up anyone else in doing so. If you want me to decide, tell me.

@nicoddemus
Copy link
Member

@ceridwen thanks!

I tried your _escape_strings function with this code:

print(_escape_strings(b'bytes-ascii'))
print(_escape_strings(u'unicode-ascii'))
print(_escape_strings(u'unicode-non-ascii:☺'))
print(_escape_strings(b'\xe7-bytes'))

Here's what I get for Python 2:

bytes-ascii
unicode-ascii
unicode-non-ascii:\u263a
\xe7-bytes

And for Python 3:

bytes-ascii
unicode-ascii
unicode-non-ascii:\u263a
\xe7-bytes

My original contribution on that part of the code was meant to show unicode ascii strings as ascii in the terminal instead of hiding them in a generic variable name, so this looks nice to me. 😉

I'm planning to repurpose test_unicode_idval_python to check for escaping. Should I change any of the other nearby tests to check for escaping?

Seems reasonable! 👍

Should I write a Hypothesis test for this code?

I'm 👍 on this, but would like to hear other's opinion too. Just in case, you should probably make that in a separate commit (in this same PR) in case anyone is 👎

Thanks again for all your work!

@The-Compiler
Copy link
Member

I'm always 👍 for hypothesis! (Honestly, it's awesome. You think your stuff is well tested, spend 5 minutes throwing some hypothesis at it, and it finds bugs you never thought about)

@ceridwen
Copy link
Contributor Author

ceridwen commented Apr 1, 2016

I have a new test failure related to escaping on Python 3:

_____________________ test_escaped_parametrized_names_xml ______________________

testdir = <Testdir local('/tmp/pytest-of-cara/pytest-933/testdir/test_escaped_parametrized_names_xml0')>

    def test_escaped_parametrized_names_xml(testdir):
        testdir.makepyfile("""
            import pytest
            @pytest.mark.parametrize('char', ["\\x00"])
            def test_func(char):
                assert char
        """)
        result, dom = runandparse(testdir)
        assert result.ret == 0
        node = dom.find_first_by_tag("testcase")
>       node.assert_attr(name="test_func[#x00]")
E       assert {'name': 'test_func[\\x00]'} == {'name': 'test_func[#x00]'}

Should I change the assertion to match or do something else?

@nicoddemus
Copy link
Member

You should change the test, the new behavior is to escape non-ascii chars. 😁

@ceridwen
Copy link
Contributor Author

ceridwen commented Apr 2, 2016

I don't know what to do with the tests that are failing to import Hypothesis or what's wrong with the format I used in CHANGELOG.rst. Someone is going to have to tell me what to do here.

@nicoddemus
Copy link
Member

Hi @ceridwen,

  1. For the failing tests in the xdist environments, there are separate environment definitions for them (here and here). I think adding hyphotesis as a dependency for testenv:py27-xdist should do the trick.
  2. The linting environment is failing with Unknown target name: "@ceridwen"., which means that you created a target for ceridwen here but did not include the actual link among the others here;

I don't know how other core contributors track PR progress, but I rely on e-mail notifications which (unfortunately) are not triggered by new commits, that might be the reason why nobody commented on your changes until now. Sorry about that.

@ceridwen
Copy link
Contributor Author

ceridwen commented Apr 2, 2016

I changed the dependencies and the changelog. The fact that commits don't trigger email notifications is a real annoyance for me.

@nicoddemus
Copy link
Member

I changed the dependencies and the changelog. The fact that commits don't trigger email notifications is a real annoyance for me.

Yep, BitBucket does, not sure why GitHub doesn't.

There are merge conflicts, could you please rebase your branch on features? Otherwise Travis and AppVeyor won't even start.

@nicoddemus
Copy link
Member

Also .hypothesis should be added to .gitignore. 😁

@ceridwen
Copy link
Contributor Author

ceridwen commented Apr 2, 2016

Is there anything else?

@nicoddemus
Copy link
Member

Looks great, thanks! 👍

I will merge this tomorrow unless someone still wants to comment on something. 😁

@nicoddemus nicoddemus merged commit e3bc6fa into pytest-dev:features Apr 3, 2016
@nicoddemus
Copy link
Member

Thanks again @ceridwen for the work and patience!

@RonnyPfannschmidt
Copy link
Member

well done

@The-Compiler
Copy link
Member

@ceridwen @nicoddemus FWIW I asked GitHub support about getting mails on PR updates, and they said they recorded it in their internal feature request tracker. I can't imagine I'm the first one to request that, but oh well... 😉

@ceridwen
Copy link
Contributor Author

ceridwen commented Apr 5, 2016

You're welcome, all.

I do wish that Github allowed updating pull requests, having the discussion for a pull request like this one in three separate threads (one issue, two pull requests) is annoying. I'm sorry for anyone who has to come read back through this discussion. Btw, someone should close the associated issue, #1351.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.02%) to 92.328% when pulling 1f46015 on ceridwen:features into da10451 on pytest-dev:features.

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.

5 participants