Skip to content
Myr

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

2 files+3 added−35 removed

modified:tests/conftest.py-32 removed
1import os2import pkgutil2import sys34import pytest5from _pytest import monkeypatch
88 unmodified lines
9495 assert leaks == []969799@pytest.fixture(params=(True, False))100def limit_loader(request, monkeypatch):101 """Patch pkgutil.get_loader to give loader without get_filename or archive.102103 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.106107 This fixture will run the testcase twice, once with and once without the108 limitation/mock.109 """110 if not request.param:111 return112113 class LimitedLoader:114 def __init__(self, loader):115 self.loader = loader116117 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)121122 old_get_loader = pkgutil.get_loader123124 def get_loader(*args, **kwargs):125 return LimitedLoader(old_get_loader(*args, **kwargs))126127 monkeypatch.setattr(pkgutil, "get_loader", get_loader)12812998@pytest.fixture99def modules_tmp_path(tmp_path, monkeypatch):100 """A temporary directory added to sys.path."""101 rv = tmp_path / "modules_tmp"
27 unmodified lines
modified:tests/test_instance_config.py+3 added-3 removed
61 unmodified lines
62 assert app.instance_path == os.fspath(project2 / "instance")636465def 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 lines
77 )787980def 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 lines
96 )979899def 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