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

[BUG] pytests incompatible with python 3.10 #2778

Open
1 task done
riya-17 opened this issue Apr 26, 2022 · 2 comments
Open
1 task done

[BUG] pytests incompatible with python 3.10 #2778

riya-17 opened this issue Apr 26, 2022 · 2 comments

Comments

@riya-17
Copy link
Member

riya-17 commented Apr 26, 2022

Is there an existing issue for this?

  • I have searched the existing issues

Description

Pytests are incompatible with latest python version 3.10

To Reproduce

Run tox -- agent python with python version 3.10

Actual Results

Running agent python3-based unit tests via pytest

Traceback (most recent call last):
  File "<frozen importlib._bootstrap>", line 939, in _find_spec
AttributeError: 'AssertionRewritingHook' object has no attribute 'find_spec'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/var/tmp/rriya/tox/py/bin/pytest", line 8, in <module>
    sys.exit(main())
  File "/var/tmp/rriya/tox/py/lib/python3.10/site-packages/_pytest/config/__init__.py", line 65, in main
    config = _prepareconfig(args, plugins)
  File "/var/tmp/rriya/tox/py/lib/python3.10/site-packages/_pytest/config/__init__.py", line 213, in _prepareconfig
    return pluginmanager.hook.pytest_cmdline_parse(
  File "/var/tmp/rriya/tox/py/lib/python3.10/site-packages/pluggy/hooks.py", line 286, in __call__
    return self._hookexec(self, self.get_hookimpls(), kwargs)
  File "/var/tmp/rriya/tox/py/lib/python3.10/site-packages/pluggy/manager.py", line 93, in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
  File "/var/tmp/rriya/tox/py/lib/python3.10/site-packages/pluggy/manager.py", line 84, in <lambda>
    self._inner_hookexec = lambda hook, methods, kwargs: hook.multicall(
  File "/var/tmp/rriya/tox/py/lib/python3.10/site-packages/pluggy/callers.py", line 203, in _multicall
    gen.send(outcome)
  File "/var/tmp/rriya/tox/py/lib/python3.10/site-packages/_pytest/helpconfig.py", line 94, in pytest_cmdline_parse
    config = outcome.get_result()
  File "/var/tmp/rriya/tox/py/lib/python3.10/site-packages/pluggy/callers.py", line 80, in get_result
    raise ex[1].with_traceback(ex[2])
  File "/var/tmp/rriya/tox/py/lib/python3.10/site-packages/pluggy/callers.py", line 187, in _multicall
    res = hook_impl.function(*args)
  File "/var/tmp/rriya/tox/py/lib/python3.10/site-packages/_pytest/config/__init__.py", line 789, in pytest_cmdline_parse
    self.parse(args)
  File "/var/tmp/rriya/tox/py/lib/python3.10/site-packages/_pytest/config/__init__.py", line 997, in parse
    self._preparse(args, addopts=addopts)
  File "/var/tmp/rriya/tox/py/lib/python3.10/site-packages/_pytest/config/__init__.py", line 943, in _preparse
    self.pluginmanager.load_setuptools_entrypoints("pytest11")
  File "/var/tmp/rriya/tox/py/lib/python3.10/site-packages/pluggy/manager.py", line 299, in load_setuptools_entrypoints
    plugin = ep.load()
  File "/usr/lib64/python3.10/importlib/metadata/__init__.py", line 171, in load
    module = import_module(match.group('module'))
  File "/usr/lib64/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 992, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 992, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/var/tmp/rriya/tox/py/lib/python3.10/site-packages/requests_mock/__init__.py", line 13, in <module>
    from requests_mock.adapter import Adapter, ANY
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1002, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 941, in _find_spec
  File "<frozen importlib._bootstrap>", line 915, in _find_spec_legacy
  File "/var/tmp/rriya/tox/py/lib/python3.10/site-packages/_pytest/assertion/rewrite.py", line 169, in find_module
    source_stat, co = _rewrite_test(self.config, fn_pypath)
  File "/var/tmp/rriya/tox/py/lib/python3.10/site-packages/_pytest/assertion/rewrite.py", line 406, in _rewrite_test
    co = compile(tree, fn.strpath, "exec", dont_inherit=True)
TypeError: required field "lineno" missing from alias
Command exited with non-zero status 1


Command: 'pytest -n auto --basetemp=/var/tmp/rriya/tox/py/tmp --cov=/var/tmp/rriya/tox/py/lib/python3.10/site-packages --cov-branch --cov-append --cov-report html:/var/tmp/rriya/tox/py/cov/html --pyargs pbench.test.unit.common pbench.test.unit.agent pbench.test.functional'
Exit status: 1
Timings: user 0.15s, system 0.01s, elapsed 0.17s (0:00.17, 98%)
Memory: max RSS 22820k, minor pf: 4405, major pf: 0, swaps 0
Context switches: inv 2, vol 1, signals 0
I/O: fs in 0, fs out 0, socket in 0, socket out 0


Agent pytest command failed with '1'

Expected Results

Pytests should have passed with an exit status of 0

Additional information

To explicitely run tests with python version 3.9 run the following Command: tox -r -e py39 -- agent python

@tirkarthi
Copy link

seems to be fixed in pytest-dev/pytest#8540

@portante
Copy link
Member

seems to be fixed in pytest-dev/pytest#8540

Thanks for the quick reply, @tirkarthi!!

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

No branches or pull requests

3 participants