pytest's `pythonpath`, from the one config file pytest takes (declaredPythonImportPaths).
(file: (name: string) => string | null)
| 911 | |
| 912 | /** pytest's `pythonpath`, from the one config file pytest takes ({@link declaredPythonImportPaths}). */ |
| 913 | function pytestPythonPath(file: (name: string) => string | null): string[] { |
| 914 | const toml = (bodies: string[]): string[] => bodies.flatMap((body) => tomlPathList(body, 'pythonpath', true)); |
| 915 | const ini = (bodies: string[]): string[] => bodies.flatMap((body) => iniPathList(body)); |
| 916 | for (const name of ['pytest.toml', '.pytest.toml']) { |
| 917 | const text = file(name); |
| 918 | if (text !== null) return toml(tableBodies(text, ['pytest'])); |
| 919 | } |
| 920 | for (const name of ['pytest.ini', '.pytest.ini']) { |
| 921 | const text = file(name); |
| 922 | if (text !== null) return ini(tableBodies(text, ['pytest'])); |
| 923 | } |
| 924 | // The other three are pytest's only with its table in them. |
| 925 | const pyproject = tableBodies(file('pyproject.toml'), ['tool.pytest', 'tool.pytest.ini_options']); |
| 926 | if (pyproject.length > 0) return toml(pyproject); |
| 927 | const tox = tableBodies(file('tox.ini'), ['pytest']); |
| 928 | if (tox.length > 0) return ini(tox); |
| 929 | return ini(tableBodies(file('setup.cfg'), ['tool:pytest'])); |
| 930 | } |
| 931 | |
| 932 | /** Pyright's and BasedPyright's project-wide `extraPaths` ({@link declaredPythonImportPaths}). */ |
| 933 | function pyrightExtraPaths(file: (name: string) => string | null): string[] { |
no test coverage detected