Answer stability round 1: 0 🔴, 1 🟡 (0 misread); list conftest.py in the help

This commit is contained in:
2026-11-27 22:58:51 +01:00
parent 58cc12b979
commit 3d49cfce40
4 changed files with 14 additions and 11 deletions
+7 -5
View File
@@ -3,13 +3,15 @@
import posixpath
import re
from mutate_changes.changed_lines import is_test, STRYKER
from mutate_changes.changed_lines import is_test
# PHPUnit's default suffix, wherever the file stands; node --test's `*-test`, `*_test`, `test-*` and `test` stems, in each suffix
# Stryker covers. node --test's `*.test.*` is `is_test`'s already.
FRAMEWORK_NAME = re.compile(rf".*Test\.php|(?:.*[-_]test|test|test-.*)(?:{'|'.join(re.escape(suffix) for suffix in STRYKER)})")
# The suffixes `node --test` runs: JavaScript, and TypeScript where Node strips the types; not `.jsx` or `.tsx`, which it doesn't find.
NODE_SUFFIXES = (".cjs", ".cts", ".js", ".mjs", ".mts", ".ts")
# PHPUnit's default suffix, wherever the file stands; node --test's `*-test`, `*_test`, `test-*` and `test` stems, in each of its
# suffixes. node --test's `*.test.*` is `is_test`'s already.
FRAMEWORK_NAME = re.compile(rf".*Test\.php|(?:.*[-_]test|test|test-.*)(?:{'|'.join(re.escape(suffix) for suffix in NODE_SUFFIXES)})")
def is_test_file(path: str) -> bool:
"""Whether path is a test by its name or folder alone, as `is_test` or PHPUnit or `node --test` tells it."""
"""Whether path is a test by its name or folder alone, as `is_test`, PHPUnit or `node --test` tells it."""
return is_test(path) or bool(FRAMEWORK_NAME.fullmatch(posixpath.basename(path)))