Skip to content
This repository was archived by the owner on Jun 9, 2025. It is now read-only.

Commit 7952da8

Browse files
committed
Remove useless code
1 parent a5a4a31 commit 7952da8

File tree

1 file changed

+1
-44
lines changed

1 file changed

+1
-44
lines changed

tests/util.py

Lines changed: 1 addition & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
11
import asyncio
22
import atexit
3-
import importlib
43
import os
54
import platform
65
import sys
76
import tempfile
8-
from collections.abc import Callable, Generator
9-
from dataclasses import dataclass
7+
from collections.abc import Generator
108
from pathlib import Path
11-
from types import ModuleType
129

1310
os.environ["PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION"] = "python"
1411

@@ -86,43 +83,3 @@ async def protoc(
8683
)
8784
stdout, stderr = await proc.communicate()
8885
return stdout, stderr, proc.returncode
89-
90-
91-
@dataclass
92-
class TestCaseJsonFile:
93-
json: str
94-
test_name: str
95-
file_name: str
96-
97-
def belongs_to(self, non_symmetrical_json: dict[str, tuple[str, ...]]) -> bool:
98-
return self.file_name in non_symmetrical_json.get(self.test_name, ())
99-
100-
101-
def find_module(module: ModuleType, predicate: Callable[[ModuleType], bool]) -> ModuleType | None:
102-
"""
103-
Recursively search module tree for a module that matches the search predicate.
104-
Assumes that the submodules are directories containing __init__.py.
105-
106-
Example:
107-
108-
# find module inside foo that contains Test
109-
import foo
110-
test_module = find_module(foo, lambda m: hasattr(m, 'Test'))
111-
"""
112-
if predicate(module):
113-
return module
114-
115-
module_path = Path(*module.__path__)
116-
117-
for sub in [sub.parent for sub in module_path.glob("**/__init__.py")]:
118-
if sub == module_path:
119-
continue
120-
sub_module_path = sub.relative_to(module_path)
121-
sub_module_name = ".".join(sub_module_path.parts)
122-
123-
sub_module = importlib.import_module(f".{sub_module_name}", module.__name__)
124-
125-
if predicate(sub_module):
126-
return sub_module
127-
128-
return None

0 commit comments

Comments
 (0)