-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
3.3.0 parametrized node IDs are not ACSII escaped :: breaks PYTEST_CURRENT_TEST in Python 3 #2957
Comments
Thanks @mattsb42-aws for reporting this issue. |
pytest is setting an env var PYTEST_CURRENT_TEST to the test name + test parameters. If parameters happen to contain NULL bytes, the putenv() call fails with "ValueError: embedded null byte". The workaround uses repr() of test parameters as parameter id. See pytest-dev/pytest#2957 Signed-off-by: Christian Heimes <cheimes@redhat.com>
pytest is setting an env var PYTEST_CURRENT_TEST to the test name + test parameters. If parameters happen to contain NULL bytes, the putenv() call fails with "ValueError: embedded null byte". The workaround uses repr() of test parameters as parameter id. See pytest-dev/pytest#2957 Signed-off-by: Christian Heimes <cheimes@redhat.com>
pytest is setting an env var PYTEST_CURRENT_TEST to the test name + test parameters. If parameters happen to contain NULL bytes, the putenv() call fails with "ValueError: embedded null byte". The workaround uses repr() of test parameters as parameter id. See pytest-dev/pytest#2957 Signed-off-by: Christian Heimes <cheimes@redhat.com>
pytest is setting an env var PYTEST_CURRENT_TEST to the test name + test parameters. If parameters happen to contain NULL bytes, the putenv() call fails with "ValueError: embedded null byte". The workaround uses repr() of test parameters as parameter id. See pytest-dev/pytest#2957 Signed-off-by: Christian Heimes <cheimes@redhat.com>
pytest is setting an env var PYTEST_CURRENT_TEST to the test name + test parameters. If parameters happen to contain NULL bytes, the putenv() call fails with "ValueError: embedded null byte". The workaround uses repr() of test parameters as parameter id. See pytest-dev/pytest#2957 Signed-off-by: Christian Heimes <cheimes@redhat.com> Reviewed-By: Alexander Bokovoy <abokovoy@redhat.com>
Strangely, that commit is available since We already have a test in place which uses null bytes during parametrization and ensures it does not break: pytest/testing/acceptance_test.py Lines 417 to 428 in 4d2f05e
And this test passes on all platforms and Python versions we test it on. I made a quick test in two local Python 3.6 installations installations I had around: 3.6.0:
3.6.3:
I had 3.6.0 mostly by accident in an old virtual environment. I took a look the changelog for Python 3.6 but did not find anything to explain this difference in behavior. After updating my local virtual environment I also get the @pytest.mark.parametrize("data", [b"\\x00", "\\x00", u'ação'])
def test_foo(data): Anyway, it seems dangerous to allow null bytes so I opened #2969 escaping null bytes in all versions. 😅 |
Weird; I didn't think to test with earlier versions of 3.6; both of the tests I ran were with 3.6.2. Maybe some combination of changes between Python 3.6.0-3.6.2 and pytest 3.2.5-3.3.0? Either way, I agree with your conclusion. Always squashing null bytes is probably the safest option. |
TBH neither did I, it happened by accident because I had a local environment with |
pytest is setting an env var PYTEST_CURRENT_TEST to the test name + test parameters. If parameters happen to contain NULL bytes, the putenv() call fails with "ValueError: embedded null byte". The workaround uses repr() of test parameters as parameter id. See pytest-dev/pytest#2957 Signed-off-by: Christian Heimes <cheimes@redhat.com> Reviewed-By: Alexander Bokovoy <abokovoy@redhat.com>
Also seeing that for borgbackup tests. Thanks for fixing it, looking forward to 3.3.1. :) |
Is there a "soon" ETA for 3.3.1 or do we need to add pytest!=3.3.0 to requirements? |
I plan to have 3.3.1 out by the end of the next week at most (possibly earlier), but by all means add |
pytest-dev/pytest#2957 should be fixed in 3.3.1.
pytest-dev/pytest#2957 (cherry picked from commit 43184f2)
pytest-dev/pytest#2957 (cherry picked from commit 43184f2)
This reverts commit 9faa2fb. Conflicts: recipe/meta.yaml This needed to be reverted because we cannot build cryptography with 3.3.0 due to pytest-dev/pytest#2957 .. we can remove this commit when 3.3.1 comes out.
pytest 3.3.1 released which fixes this issue |
This reverts commit 5ba9bb8.
Revert "Work around pytest-dev/pytest#2957"
pytest is setting an env var PYTEST_CURRENT_TEST to the test name + test parameters. If parameters happen to contain NULL bytes, the putenv() call fails with "ValueError: embedded null byte". The workaround uses repr() of test parameters as parameter id. See pytest-dev/pytest#2957 Signed-off-by: Christian Heimes <cheimes@redhat.com> Reviewed-By: Alexander Bokovoy <abokovoy@redhat.com>
Problem
With
3.3.0
, it appears that there were some conflicting changes in the formatting of parametrized node IDs which results in errors in Python 3 if the parametrized values contain null bytes.I noticed this behavior because setting the
PYTEST_CURRENT_TEST
environment variable now fails in Python 3 in this scenario. Digging deeper, it appears that the immediate reason for this error is this commit that indicates that ascii escaping is no longer necessary because it is sanitized during the parametrization process.However, looking at the values that it attempts to write to the environment variable and the formatted names for the parametrized tests, it would appear that the parametrized node ID is not actually being ASCII sanitized.
Details
OS
Darwin 186590df9307.ant.amazon.com 16.7.0 Darwin Kernel Version 16.7.0: Wed Oct 4 00:17:00 PDT 2017; root:xnu-3789.71.6~1/RELEASE_X86_64 x86_64
Isolated test code
Test/pip list with
pytest 3.2.5
pytest 3.3.0
The text was updated successfully, but these errors were encountered: