pytest-dev / pytest-bdd

BDD library for the pytest runner
https://pytest-bdd.readthedocs.io/en/latest/
MIT License
1.32k stars 221 forks source link

Python 3.8/pytest 3.0.4/pytest-bdd 3.1.0 crash: TypeError: an integer is required (got type bytes) #676

Closed uhohitsjennaaa closed 8 months ago

uhohitsjennaaa commented 8 months ago

I'm trying to implement pytest-bdd in an existing pytest framework, which uses pytest 3.0.4 and python 3.8. After installing pytest-bdd 3.1.0 (the last version to support this version of pytest), I get the following error:

Traceback (most recent call last):
  File ".tox/py38-bdd/bin/py.test", line 8, in <module>
    sys.exit(main())
  File ".tox/py38-bdd/lib/python3.8/site-packages/_pytest/config.py", line 47, in main
    config = _prepareconfig(args, plugins)
  File ".tox/py38-bdd/lib/python3.8/site-packages/_pytest/config.py", line 131, in _prepareconfig
    return pluginmanager.hook.pytest_cmdline_parse(
  File ".tox/py38-bdd/lib/python3.8/site-packages/_pytest/vendored_packages/pluggy.py", line 745, in __call__
    return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
  File ".tox/py38-bdd/lib/python3.8/site-packages/_pytest/vendored_packages/pluggy.py", line 339, in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
  File ".tox/py38-bdd/lib/python3.8/site-packages/_pytest/vendored_packages/pluggy.py", line 334, in <lambda>
    _MultiCall(methods, kwargs, hook.spec_opts).execute()
  File ".tox/py38-bdd/lib/python3.8/site-packages/_pytest/vendored_packages/pluggy.py", line 613, in execute
    return _wrapped_call(hook_impl.function(*args), self.execute)
  File ".tox/py38-bdd/lib/python3.8/site-packages/_pytest/vendored_packages/pluggy.py", line 250, in _wrapped_call
    wrap_controller.send(call_outcome)
  File ".tox/py38-bdd/lib/python3.8/site-packages/_pytest/helpconfig.py", line 32, in pytest_cmdline_parse
    config = outcome.get_result()
  File ".tox/py38-bdd/lib/python3.8/site-packages/_pytest/vendored_packages/pluggy.py", line 279, in get_result
    raise ex[1].with_traceback(ex[2])
  File ".tox/py38-bdd/lib/python3.8/site-packages/_pytest/vendored_packages/pluggy.py", line 265, in __init__
    self.result = func()
  File ".tox/py38-bdd/lib/python3.8/site-packages/_pytest/vendored_packages/pluggy.py", line 614, in execute
    res = hook_impl.function(*args)
  File ".tox/py38-bdd/lib/python3.8/site-packages/_pytest/config.py", line 882, in pytest_cmdline_parse
    self.parse(args)
  File ".tox/py38-bdd/lib/python3.8/site-packages/_pytest/config.py", line 1038, in parse
    self._preparse(args, addopts=addopts)
  File ".tox/py38-bdd/lib/python3.8/site-packages/_pytest/config.py", line 1001, in _preparse
    self.pluginmanager.load_setuptools_entrypoints(entrypoint_name)
  File ".tox/py38-bdd/lib/python3.8/site-packages/_pytest/vendored_packages/pluggy.py", line 510, in load_setuptools_entrypoints
    plugin = ep.load()
  File ".tox/py38-bdd/lib/python3.8/site-packages/pkg_resources/__init__.py", line 2471, in load
    return self.resolve()
  File ".tox/py38-bdd/lib/python3.8/site-packages/pkg_resources/__init__.py", line 2477, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 655, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 618, in _load_backward_compatible
  File ".tox/py38-bdd/lib/python3.8/site-packages/_pytest/assertion/rewrite.py", line 212, in load_module
    py.builtin.exec_(co, mod.__dict__)
  File ".tox/py38-bdd/lib/python3.8/site-packages/pytest_bdd/plugin.py", line 27, in <module>
    def trace():
  File ".tox/py38-bdd/lib/python3.8/site-packages/pytest_bdd/steps.py", line 188, in decorator
    contribute_to_module(
  File ".tox/py38-bdd/lib/python3.8/site-packages/pytest_bdd/steps.py", line 261, in contribute_to_module
    func = recreate_function(func, module=module)
  File ".tox/py38-bdd/lib/python3.8/site-packages/pytest_bdd/steps.py", line 245, in recreate_function
    set_code(func, CodeType(*args))
TypeError: an integer is required (got type bytes)

This was previously reported in #354, but the resolution was simply to use a newer pytest-bdd version. Is it possible to fix this given my project requirements (pytest 3.0.4, python 3.8)?

uhohitsjennaaa commented 8 months ago

In looking at recreate_function in steps.py, it looks like six is referenced. The framework I am working in also requires six 1.12.0.

youtux commented 8 months ago

Sorry, I have barely enough time to keep this project working with the supported versions of python, I definitely won’t support an ancient version. You can always fork this project and fix that particular version.