File size: 756 Bytes
53b2ac9 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | # SPDX-License-Identifier: MIT
"""TrashClaw runs on old machines: the main file and plugins must parse
with Python 3.7 grammar (no walrus, positional-only params, match, etc.)."""
import ast
import glob
import os
import sys
import pytest
ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
FILES = [os.path.join(ROOT, "trashclaw.py")] + sorted(
glob.glob(os.path.join(ROOT, "plugins", "*.py")))
@pytest.mark.skipif(sys.version_info < (3, 8), reason="feature_version needs Python 3.8+")
@pytest.mark.parametrize("path", FILES, ids=lambda p: os.path.relpath(p, ROOT))
def test_parses_as_python37(path):
with open(path, encoding="utf-8") as f:
source = f.read()
ast.parse(source, filename=path, feature_version=(3, 7))
|