pytest-dev / pytest

The pytest framework makes it easy to write small tests, yet scales to support complex functional testing
https://pytest.org
MIT License
12.11k stars 2.68k forks source link

Assertion rewriting breaks jedi due to missing InspectLoader support #6643

Open iwanb opened 4 years ago

iwanb commented 4 years ago

platform linux -- Python 3.7.6, pytest-5.3.4, py-1.6.0, pluggy-0.12.0

I am using IPython with jedi completions within a pytest session. Assertion rewriting is enabled, but doing completions on rewritten modules crashes jedi because mod.__loader__.is_package is not implemented. https://docs.python.org/3/library/importlib.html#importlib.abc.InspectLoader

AFAIK is would be best if the importer subclass those: https://docs.python.org/3/library/importlib.html#importlib.abc.FileLoader https://docs.python.org/3/library/importlib.html#importlib.abc.SourceLoader

To get all the methods implemented.

See the trace at https://github.com/davidhalter/jedi/issues/1487

This is probably related to https://github.com/pytest-dev/pytest/pull/3919 where is_package was removed.

RonnyPfannschmidt commented 4 years ago

as by now the mainline no longer supports python 2, i think we can investigate sorting this out by using more of importlib

thanks for bringing this up

blueyed commented 4 years ago

This is probably related to #3919 where is_package was removed.

It was removed in 4cd08f9b5 (https://github.com/pytest-dev/pytest/pull/5468). Not sure if bug or enhancement though. (btw: the Jedi issue was fixed already)