Skip to content

Commit

Permalink
Add test for packages with broken metadata
Browse files Browse the repository at this point in the history
Related to pytest-dev#5389
  • Loading branch information
nicoddemus committed Jun 4, 2019
1 parent ee50e15 commit 8a2d583
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions testing/test_config.py
Expand Up @@ -586,6 +586,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()


@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)
Expand Down

0 comments on commit 8a2d583

Please sign in to comment.