remove tests about deprecated pkgutil.get_loader (#5702)
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by David Lord · committed by GitHub · parents 2732c4d, 41ec576 · Browse files · 2 files·+3 added−35 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
2 files+3 added−35 removed
- tests:+3 added−35 removed
Provenance
- Commit
73ce26c- Tree
5dbbad3- Author
David Lord <davidism@gmail.com>- Committer
GitHub <noreply@github.com>- Parent 1
2732c4d- Parent 2
41ec576
2 files changed+3 added−35 removed
modified:tests/conftest.py-32 removed
1 import os2-import pkgutil2 import sys3 4 import pytest5 from _pytest import monkeypatch88 unmodified lines94 95 assert leaks == []96 97 99-@pytest.fixture(params=(True, False))100-def limit_loader(request, monkeypatch):101- """Patch pkgutil.get_loader to give loader without get_filename or archive.102-103- This provides for tests where a system has custom loaders, e.g. Google App104- Engine's HardenedModulesHook, which have neither the `get_filename` method105- nor the `archive` attribute.106-107- This fixture will run the testcase twice, once with and once without the108- limitation/mock.109- """110- if not request.param:111- return112-113- class LimitedLoader:114- def __init__(self, loader):115- self.loader = loader116-117- def __getattr__(self, name):118- if name in {"archive", "get_filename"}:119- raise AttributeError(f"Mocking a loader which does not have {name!r}.")120- return getattr(self.loader, name)121-122- old_get_loader = pkgutil.get_loader123-124- def get_loader(*args, **kwargs):125- return LimitedLoader(old_get_loader(*args, **kwargs))126-127- monkeypatch.setattr(pkgutil, "get_loader", get_loader)128-129-98 @pytest.fixture99 def modules_tmp_path(tmp_path, monkeypatch):100 """A temporary directory added to sys.path."""101 rv = tmp_path / "modules_tmp"27 unmodified linesmodified:tests/test_instance_config.py+3 added-3 removed
61 unmodified lines62 assert app.instance_path == os.fspath(project2 / "instance")63 64 65 def test_installed_module_paths(66- modules_tmp_path, modules_tmp_path_prefix, purge_module, site_packages, limit_loader66+ modules_tmp_path, modules_tmp_path_prefix, purge_module, site_packages67 ):68 (site_packages / "site_app.py").write_text(69 "import flask\napp = flask.Flask(__name__)\n"70 )6 unmodified lines77 )78 79 80 def test_installed_package_paths(81- limit_loader, modules_tmp_path, modules_tmp_path_prefix, purge_module, monkeypatch81+ modules_tmp_path, modules_tmp_path_prefix, purge_module, monkeypatch82 ):83 installed_path = modules_tmp_path / "path"84 installed_path.mkdir()85 monkeypatch.syspath_prepend(installed_path)10 unmodified lines96 )97 98 99 def test_prefix_package_paths(100- limit_loader, modules_tmp_path, modules_tmp_path_prefix, purge_module, site_packages100+ modules_tmp_path, modules_tmp_path_prefix, purge_module, site_packages101 ):102 app = site_packages / "site_package"103 app.mkdir()104 (app / "__init__.py").write_text("import flask\napp = flask.Flask(__name__)\n")7 unmodified lines