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

Problem with pytest and prysk on Ubuntu 20.04 and Python 3.8 #190

Closed
nigels-com opened this issue May 22, 2023 · 9 comments · Fixed by #214
Closed

Problem with pytest and prysk on Ubuntu 20.04 and Python 3.8 #190

nigels-com opened this issue May 22, 2023 · 9 comments · Fixed by #214
Assignees
Labels
bug Something isn't working

Comments

@nigels-com
Copy link
Collaborator

nigels-com commented May 22, 2023

We have a docker container based on ubuntu:focal using pytest via apt-get install -y python3-pytest and Prysk via pip3 install prysk.

Some pytest things started breaking with Pyrsk > 0.12.2

$ python3.8 -m pytest
Traceback (most recent call last):
  File "/usr/lib/python3.8/runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib/python3.8/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/usr/lib/python3/dist-packages/pytest.py", line 102, in <module>
    raise SystemExit(pytest.main())
  File "/usr/lib/python3/dist-packages/_pytest/config/__init__.py", line 63, in main
    config = _prepareconfig(args, plugins)
  File "/usr/lib/python3/dist-packages/_pytest/config/__init__.py", line 206, in _prepareconfig
    return pluginmanager.hook.pytest_cmdline_parse(
  File "/usr/lib/python3/dist-packages/pluggy/hooks.py", line 286, in __call__
    return self._hookexec(self, self.get_hookimpls(), kwargs)
  File "/usr/lib/python3/dist-packages/pluggy/manager.py", line 92, in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
  File "/usr/lib/python3/dist-packages/pluggy/manager.py", line 83, in <lambda>
    self._inner_hookexec = lambda hook, methods, kwargs: hook.multicall(
  File "/usr/lib/python3/dist-packages/pluggy/callers.py", line 203, in _multicall
    gen.send(outcome)
  File "/usr/lib/python3/dist-packages/_pytest/helpconfig.py", line 94, in pytest_cmdline_parse
    config = outcome.get_result()
  File "/usr/lib/python3/dist-packages/pluggy/callers.py", line 80, in get_result
    raise ex[1].with_traceback(ex[2])
  File "/usr/lib/python3/dist-packages/pluggy/callers.py", line 187, in _multicall
    res = hook_impl.function(*args)
  File "/usr/lib/python3/dist-packages/_pytest/config/__init__.py", line 739, in pytest_cmdline_parse
    self.parse(args)
  File "/usr/lib/python3/dist-packages/_pytest/config/__init__.py", line 947, in parse
    self._preparse(args, addopts=addopts)
  File "/usr/lib/python3/dist-packages/_pytest/config/__init__.py", line 893, in _preparse
    self.pluginmanager.load_setuptools_entrypoints("pytest11")
  File "/usr/lib/python3/dist-packages/pluggy/manager.py", line 297, in load_setuptools_entrypoints
    plugin = ep.load()
  File "/usr/lib/python3.8/importlib/metadata.py", line 77, in load
    module = import_module(match.group('module'))
  File "/usr/lib/python3.8/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  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 671, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 848, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/usr/local/lib/python3.8/dist-packages/pytest_prysk/__init__.py", line 120, in <module>
    class Item(pytest.Item):
  File "/usr/local/lib/python3.8/dist-packages/pytest_prysk/__init__.py", line 151, in Item
    excinfo: ExceptionInfo[BaseException],
TypeError: 'type' object is not subscriptable

Compared to 0.12.2, which does not throw the exception.

@Nicoretti
Copy link
Member

Hi @nigels-com,

thanks for reporting the issue. A couple of questions from my side:

  • Did you install prysk with or without pytest support?
  • Why not let pip install the required dependencies?
    • From my experience, mixing packaging system rarely is a good idea
  • Which pytest version is installed by apt-get install -y python3-pytest
    • pytest -p no:prysk --version should do the trick

best
Nico

@Nicoretti Nicoretti self-assigned this May 22, 2023
@nigels-com
Copy link
Collaborator Author

  1. prysk is installed without pytest support:

  2. Aim of this docker container is to be baseline Ununtu 20.04 focal, so trying work with the version of pytest provided by that.

$ python3 -m pytest no:prysk --version
This is pytest version 4.6.9, imported from /usr/lib/python3/dist-packages/pytest.py

@Nicoretti Nicoretti added the bug Something isn't working label May 23, 2023
@Nicoretti
Copy link
Member

Nicoretti commented May 23, 2023

Hi @nigels-com,

thanks for your feedback. I am fairly sure the problem is that the pytest-prysk entry point is installed even if it is not required explicitly. In combination with an incompatible pytest version this causes pytest to crash.
This is definitely a bug from my point of view. The next weeks I'll be quite busy, until I find the time to fix it you have 3 options from my point of view.

  • use a prysk version <= 0.12.2
  • when executing pytest make sure it will ignore the prysk entry point
    • by passing -p no:prysk to the cli
    • by configuring pytest
     # pytest.ini
      [pytest]
      addopts = -p no:prysk
     # pyproject.toml
     [tool.pytest.ini_options]
     addopts = "-p no:prysk"
  • install a pytest version compatible with the prysk plugin e.g. by using the feature flag pip install "prysk[pytest-plugin]"

Hope that helps until I can supply a fix.

best
Nico

@Nicoretti
Copy link
Member

We need to check if a plugin entry point can be made dependent on an extra, similar to what can be done with scripts.

@nigels-com
Copy link
Collaborator Author

nigels-com commented May 23, 2023

Thanks for that!

We've pinned prysk to 0.12.2 for now, and that looks fine for both Ubuntu 20.04 and 22.04.
For Ubuntu 18.04 (which we're gradually phasing out) it's an older Python/pip but enough for what we need.

Also wanted to mention that we voted for Czechia in the Eurovision final last week, but alas Australia was not feeling the audience vote love either (again!).

-- Nigel

@Nicoretti
Copy link
Member

Hi @nigels-com,

quick update, I started to factor out the pytest-plugin.
Once I am done with it, we will be able to address this issue.

best
Nico

@Nicoretti
Copy link
Member

Nicoretti commented Aug 14, 2023

Ongoing, I am bit short on time these days.
Factoring out is mostly done see here.
Testing and hooking up in prysk is pending.

@Nicoretti
Copy link
Member

Nicoretti commented Nov 5, 2023

Update: migration/extraction is done, testing and updating the dependency on prysk side is required.

@Nicoretti
Copy link
Member

@nigels-com I've just merged the factoring out of the pytest plugin, I'll create a release on the weekend.
Then prysk should work fine for you again ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants