forked from microsoft/python-type-stubs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_tests.py
More file actions
44 lines (33 loc) · 1.16 KB
/
run_tests.py
File metadata and controls
44 lines (33 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import os
import subprocess
import sys
from pathlib import Path
def install_requirements(test_folder: Path):
print("\nInstalling requirements...")
return subprocess.run(
(sys.executable, "-m", "pip", "install", "--upgrade", "-r", os.path.join(test_folder, "requirements.txt"))
)
def run_pyright():
print("\nRunning Pyright...")
# https://github.com/RobertCraigie/pyright-python#keeping-pyright-and-pylance-in-sync
os.environ.pop("PYRIGHT_PYTHON_FORCE_VERSION", None)
os.environ["PYRIGHT_PYTHON_PYLANCE_VERSION"] = "latest-prerelease"
return subprocess.run((sys.executable, "-m", "pyright"))
def run_mypy():
print("\nRunning mypy...")
return subprocess.run((sys.executable, "-m", "mypy", "."))
def main():
test_folder = Path(__file__).parent
root = test_folder.parent
os.chdir(root)
install_requirements(test_folder).check_returncode()
results = (
run_mypy(),
run_pyright(),
)
if sum([result.returncode for result in results]) > 0:
print("\nOne or more tests failed. See above for details.")
else:
print("\nAll tests passed!")
if __name__ == "__main__":
main()