Skip to content

Commit 73ce26c

Browse files
authored
remove tests about deprecated pkgutil.get_loader (#5702)
2 parents 2732c4d + 41ec576 commit 73ce26c

File tree

2 files changed

+3
-35
lines changed

2 files changed

+3
-35
lines changed

tests/conftest.py

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import os
2-
import pkgutil
32
import sys
43

54
import pytest
@@ -96,37 +95,6 @@ def leak_detector():
9695
assert leaks == []
9796

9897

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 App
104-
Engine's HardenedModulesHook, which have neither the `get_filename` method
105-
nor the `archive` attribute.
106-
107-
This fixture will run the testcase twice, once with and once without the
108-
limitation/mock.
109-
"""
110-
if not request.param:
111-
return
112-
113-
class LimitedLoader:
114-
def __init__(self, loader):
115-
self.loader = loader
116-
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_loader
123-
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-
13098
@pytest.fixture
13199
def modules_tmp_path(tmp_path, monkeypatch):
132100
"""A temporary directory added to sys.path."""

tests/test_instance_config.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def create_namespace(package):
6363

6464

6565
def test_installed_module_paths(
66-
modules_tmp_path, modules_tmp_path_prefix, purge_module, site_packages, limit_loader
66+
modules_tmp_path, modules_tmp_path_prefix, purge_module, site_packages
6767
):
6868
(site_packages / "site_app.py").write_text(
6969
"import flask\napp = flask.Flask(__name__)\n"
@@ -78,7 +78,7 @@ def test_installed_module_paths(
7878

7979

8080
def test_installed_package_paths(
81-
limit_loader, modules_tmp_path, modules_tmp_path_prefix, purge_module, monkeypatch
81+
modules_tmp_path, modules_tmp_path_prefix, purge_module, monkeypatch
8282
):
8383
installed_path = modules_tmp_path / "path"
8484
installed_path.mkdir()
@@ -97,7 +97,7 @@ def test_installed_package_paths(
9797

9898

9999
def test_prefix_package_paths(
100-
limit_loader, modules_tmp_path, modules_tmp_path_prefix, purge_module, site_packages
100+
modules_tmp_path, modules_tmp_path_prefix, purge_module, site_packages
101101
):
102102
app = site_packages / "site_package"
103103
app.mkdir()

0 commit comments

Comments
 (0)