question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

pytest 3.2 breaks pytest.mark.parametrize with null bytes

See original GitHub issue
(tempenv-543d64822ecc) ~/.v/tempenv-543d64822ecc ❯❯❯ pip install "pytest<3.2"
Collecting pytest<3.2
  Using cached pytest-3.1.3-py2.py3-none-any.whl
Requirement already satisfied: py>=1.4.33 in ./lib/python2.7/site-packages (from pytest<3.2)
Requirement already satisfied: setuptools in ./lib/python2.7/site-packages (from pytest<3.2)
Installing collected packages: pytest
  Found existing installation: pytest 3.2.0
    Uninstalling pytest-3.2.0:
      Successfully uninstalled pytest-3.2.0
Successfully installed pytest-3.1.3
(tempenv-543d64822ecc) ~/.v/tempenv-543d64822ecc ❯❯❯ cat test.py
import pytest


@pytest.mark.parametrize("data", ["\x00"])
def test_foo(data):
    assert data
(tempenv-543d64822ecc) ~/.v/tempenv-543d64822ecc ❯❯❯ py.test  test.py
====================================================== test session starts =======================================================
platform darwin -- Python 2.7.13, pytest-3.1.3, py-1.4.34, pluggy-0.4.0
rootdir: /Users/alex_gaynor/.virtualenvs/tempenv-543d64822ecc, inifile:
collected 1 item s

test.py .

==================================================== 1 passed in 0.01 seconds ====================================================
(tempenv-543d64822ecc) ~/.v/tempenv-543d64822ecc ❯❯❯ pip install -U pytest
Collecting pytest
  Using cached pytest-3.2.0-py2.py3-none-any.whl
Requirement already up-to-date: py>=1.4.33 in ./lib/python2.7/site-packages (from pytest)
Requirement already up-to-date: setuptools in ./lib/python2.7/site-packages (from pytest)
Installing collected packages: pytest
  Found existing installation: pytest 3.1.3
    Uninstalling pytest-3.1.3:
      Successfully uninstalled pytest-3.1.3
Successfully installed pytest-3.2.0
(tempenv-543d64822ecc) ~/.v/tempenv-543d64822ecc ❯❯❯ py.test  test.py
====================================================== test session starts =======================================================
platform darwin -- Python 2.7.13, pytest-3.2.0, py-1.4.34, pluggy-0.4.0
rootdir: /Users/alex_gaynor/.virtualenvs/tempenv-543d64822ecc, inifile:
collected 1 item s

test.py EE

============================================================= ERRORS =============================================================
_________________________________________________ ERROR at setup of test_foo[] __________________________________________________

self = {'TERM_PROGRAM_VERSION': '3.0.15', 'LOGNAME': 'alex_gaynor', 'USER': 'alex_gaynor', 'HOME': '/Users/alex_gaynor', 'PAT..._ENCODING': '0x1F5:0x0:0x0', 'PWD': '/Users/alex_gaynor/.virtualenvs/tempenv-543d64822ecc', 'COMMAND_MODE': 'unix2003'}
key = 'PYTEST_CURRENT_TEST', item = 'test.py::test_foo[\x00] (setup)'

    def __setitem__(self, key, item):
>       putenv(key, item)
E       TypeError: putenv() argument 2 must be string without null bytes, not str

lib/python2.7/os.py:473: TypeError
________________________________________________ ERROR at teardown of test_foo[] ________________________________________________

self = {'TERM_PROGRAM_VERSION': '3.0.15', 'LOGNAME': 'alex_gaynor', 'USER': 'alex_gaynor', 'HOME': '/Users/alex_gaynor', 'PAT..._ENCODING': '0x1F5:0x0:0x0', 'PWD': '/Users/alex_gaynor/.virtualenvs/tempenv-543d64822ecc', 'COMMAND_MODE': 'unix2003'}
key = 'PYTEST_CURRENT_TEST', item = 'test.py::test_foo[\x00] (teardown)'

    def __setitem__(self, key, item):
>       putenv(key, item)
E       TypeError: putenv() argument 2 must be string without null bytes, not str

lib/python2.7/os.py:473: TypeError
==================================================== 2 error in 0.07 seconds =====================================================
(tempenv-543d64822ecc) ~/.v/tempenv-543d64822ecc ❯❯❯

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:12 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
The-Compilercommented, Nov 28, 2017
1reaction
tirancommented, Aug 3, 2017

@nicoddemus sure, that’s fine with me. Thanks for your fix!

For rawhide I simply removed the test case. F26 has an older pytest version.

Read more comments on GitHub >

github_iconTop Results From Across the Web

API Reference — pytest documentation
Specify a parameter in pytest.mark.parametrize calls or parametrized fixtures. ... Clearing those references breaks a reference cycle ( ExceptionInfo ...
Read more >
pytest Documentation
2.3.11 Using marks with parametrized fixtures pytest.param() can be used to apply marks in values sets of parametrized fixtures in the same ...
Read more >
Reference — pytest documentation
Specify a parameter in pytest.mark.parametrize calls or parametrized fixtures. ... Clearing those references breaks a reference cycle ( ExceptionInfo ...
Read more >
python-pytest-3.3.2-bp150.2.4
- fix #1087: handling SystemError when passing empty byte strings to pytest.parametrize in Python 3. Thanks Paul Kehrer for the report and Bruno...
Read more >
mozilla-central: changeset 568432 ...
testing/web-platform/tests/tools/third_party/pytest/bench/empty.py ... more than 2 positional arguments to ``pytest.mark.parametrize``.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found