Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/jmrplens/phonometry. Standards-conformant acoustics library for Python: measurement and metrology, docs.jmrp.io/phonometry
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031323334353637383940# Copyright (c) 2026. Jose Manuel Requena Plens"""The test modules tied to the pinned figure stack, read without importing them.
The figure, diagram and badge tooling compares against artefacts drawn on thepinned stack in ``requirements*.txt``, and some of it imports names an oldermatplotlib does not have. Its test modules declare that at module level::
pytestmark = pytest.mark.pinned_stack
The minimum-versions CI job runs ``pytest --without-pinned-stack`` at thedependency floors. A mark alone cannot keep such a module out of that run: amark is read after the module is imported, and the import is what fails. So``conftest.py`` reads the declaration from the source with :func:`declares`and leaves the module out before it is imported."""
from __future__ import annotations
import ast
#: The mark a module carries, and the option that leaves those modules out.MARK = "pinned_stack"OPTION = "--without-pinned-stack"
def declares(source: str) -> bool: """Whether a module's own ``pytestmark`` names :data:`MARK`.""" for node in ast.parse(source).body: if not isinstance(node, ast.Assign | ast.AnnAssign): continue targets = node.targets if isinstance(node, ast.Assign) else [node.target] if not any(isinstance(t, ast.Name) and t.id == "pytestmark" for t in targets): continue if node.value is not None and any( isinstance(sub, ast.Attribute) and sub.attr == MARK for sub in ast.walk(node.value) ): return True return False