generated from mononoki/pyproj
[+] mvp1
basic working mvp
This commit is contained in:
27
tests/test_source_validation.py
Normal file
27
tests/test_source_validation.py
Normal file
@@ -0,0 +1,27 @@
|
||||
"""Проверки исходников, которые работают даже при ошибках импорта сервера."""
|
||||
|
||||
import ast
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
def test_all_python_sources_compile():
|
||||
"""Проверяет синтаксис всех серверных модулей и клиента без запуска и записи pyc."""
|
||||
errors = []
|
||||
for path in sorted((Path(__file__).parents[1] / "src").rglob("*.py")):
|
||||
try:
|
||||
compile(path.read_text(encoding="utf-8"), str(path), "exec")
|
||||
except SyntaxError as error:
|
||||
errors.append(f"{path.relative_to(Path(__file__).parents[1])}:{error.lineno}: {error.msg}")
|
||||
assert not errors, "\n".join(errors)
|
||||
|
||||
|
||||
def test_every_test_has_a_description():
|
||||
"""Проверяет наличие краткого docstring у каждого теста набора."""
|
||||
missing = []
|
||||
for path in Path(__file__).parent.glob("test_*.py"):
|
||||
tree = ast.parse(path.read_text(encoding="utf-8"))
|
||||
for node in ast.walk(tree):
|
||||
if isinstance(node, (ast.FunctionDef, ast.AsyncFunctionDef)) and node.name.startswith("test_"):
|
||||
if not ast.get_docstring(node):
|
||||
missing.append(f"{path.name}:{node.lineno}: {node.name}")
|
||||
assert not missing, "\n".join(missing)
|
||||
Reference in New Issue
Block a user