feat(pytest): use python_functions config option (#100)

This commit is contained in:
nicos68
2025-06-23 23:28:18 +02:00
committed by GitHub
parent 34c9f6f3dc
commit ed9b4d794b
4 changed files with 64 additions and 17 deletions

View File

@@ -58,6 +58,13 @@ def main(argv: List[str]):
collect(argv)
return
if "--pytest-extract-test-name-template" in argv:
argv.remove("--pytest-extract-test-name-template")
from .pytest import extract_test_name_template
extract_test_name_template(argv)
return
args = parser.parse_args(argv)
adapter = get_adapter(TestRunner(args.runner), args.emit_parameterized_ids)

View File

@@ -1,4 +1,5 @@
from io import StringIO
import json
from pathlib import Path
from typing import Callable, Dict, List, Optional, Union
@@ -205,5 +206,16 @@ class NeotestDebugpyPlugin:
additional_info.is_tracing -= 1
class TestNameTemplateExtractor:
@staticmethod
def pytest_collection_modifyitems(config):
config = {"python_functions": config.getini("python_functions")[0]}
print(f"\n{json.dumps(config)}\n")
def extract_test_name_template(args):
pytest.main(args=["-k", "neotest_none"], plugins=[TestNameTemplateExtractor])
def collect(args):
pytest.main(["--collect-only", "--verbosity=0", "-q"] + args)