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

fix logic if importlib_metadata.PathDistribution.files is None [breaks pytest 4.6.0|1|2] #5389

Merged
merged 3 commits into from Jun 4, 2019
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

@@ -0,0 +1 @@
Fix regressions of `#5063 <https://github.com/pytest-dev/pytest/pull/5063>`__ for ``importlib_metadata.PathDistribution`` which have their ``files`` attribute being ``None``.
@@ -784,7 +784,7 @@ def _mark_plugins_for_rewrite(self, hook):
str(file)
for dist in importlib_metadata.distributions()
if any(ep.group == "pytest11" for ep in dist.entry_points)
for file in dist.files
for file in dist.files or []
)

for name in _iter_rewritable_modules(package_files):
@@ -578,6 +578,29 @@ def distributions():
testdir.parseconfig()


def test_importlib_metadata_broken_distribution(testdir, monkeypatch):
"""Integration test for broken distributions with 'files' metadata being None (#5389)"""
monkeypatch.delenv("PYTEST_DISABLE_PLUGIN_AUTOLOAD", raising=False)

class DummyEntryPoint:
name = "mytestplugin"
group = "pytest11"

def load(self):
return object()

class Distribution:
version = "1.0"
files = None
entry_points = (DummyEntryPoint(),)

def distributions():
return (Distribution(),)

monkeypatch.setattr(importlib_metadata, "distributions", distributions)
testdir.parseconfig()
This conversation was marked as resolved by blueyed

This comment has been minimized.

Copy link
@blueyed

blueyed Jun 5, 2019

Contributor

The test fails with usedevelop = True in tox:

…/py37-coverage/lib/python3.7/site-packages/_pytest/config/__init__.py:625: in _iter_rewritable_modules
    for fn in package_files:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

.0 = <tuple_iterator object at 0x7f6fe75dfeb8>

        str(file)
        for dist in importlib_metadata.distributions()
        if any(ep.group == "pytest11" for ep in dist.entry_points)
>       for file in dist.files
    )
E   TypeError: 'NoneType' object is not iterable


@pytest.mark.parametrize("block_it", [True, False])
def test_plugin_preparse_prevents_setuptools_loading(testdir, monkeypatch, block_it):
monkeypatch.delenv("PYTEST_DISABLE_PLUGIN_AUTOLOAD", raising=False)
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.