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
41 lines (30 loc) · 1.1 KB
/
run_tests.py
File metadata and controls
41 lines (30 loc) · 1.1 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
import os
import subprocess
import sys
from pathlib import Path
def install_requirements():
print("\nInstalling requirements...")
subprocess.check_call((sys.executable, "-m", "pip", "install", "pip>=25.1"))
subprocess.check_call((sys.executable, "-m", "pip", "install", "--upgrade", "--group", "tests"))
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():
os.chdir(Path(__file__).parent.parent)
install_requirements()
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()