Merge pull request #5389 from dirk-thomas/patch-1
fix logic if importlib_metadata.PathDistribution.files is None [breaks pytest 4.6.0|1|2]
This commit is contained in:
		
						commit
						79ef04888e
					
				| 
						 | 
					@ -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 @@ class Config:
 | 
				
			||||||
            str(file)
 | 
					            str(file)
 | 
				
			||||||
            for dist in importlib_metadata.distributions()
 | 
					            for dist in importlib_metadata.distributions()
 | 
				
			||||||
            if any(ep.group == "pytest11" for ep in dist.entry_points)
 | 
					            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):
 | 
					        for name in _iter_rewritable_modules(package_files):
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -578,6 +578,29 @@ def test_setuptools_importerror_issue1479(testdir, monkeypatch):
 | 
				
			||||||
        testdir.parseconfig()
 | 
					        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])
 | 
					@pytest.mark.parametrize("block_it", [True, False])
 | 
				
			||||||
def test_plugin_preparse_prevents_setuptools_loading(testdir, monkeypatch, block_it):
 | 
					def test_plugin_preparse_prevents_setuptools_loading(testdir, monkeypatch, block_it):
 | 
				
			||||||
    monkeypatch.delenv("PYTEST_DISABLE_PLUGIN_AUTOLOAD", raising=False)
 | 
					    monkeypatch.delenv("PYTEST_DISABLE_PLUGIN_AUTOLOAD", raising=False)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue