A function is a test if its name matches test patterns, it lives in a test file and has a test-runner name, or it has a @Test annotation.
(
name: str, file_path: str, decorators: tuple[str, ...] = (),
)
| 771 | |
| 772 | |
| 773 | def _is_test_function( |
| 774 | name: str, file_path: str, decorators: tuple[str, ...] = (), |
| 775 | ) -> bool: |
| 776 | """A function is a test if its name matches test patterns, it lives |
| 777 | in a test file and has a test-runner name, or it has a @Test annotation. |
| 778 | """ |
| 779 | if any(p.search(name) for p in _TEST_PATTERNS): |
| 780 | return True |
| 781 | if _is_test_file(file_path) and name in _TEST_RUNNER_NAMES: |
| 782 | return True |
| 783 | if decorators and any(d in _TEST_ANNOTATIONS for d in decorators): |
| 784 | return True |
| 785 | return False |
| 786 | |
| 787 | |
| 788 | def file_hash(path: Path) -> str: |
no test coverage detected