-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdo_test.py
More file actions
27 lines (25 loc) · 738 Bytes
/
Copy pathdo_test.py
File metadata and controls
27 lines (25 loc) · 738 Bytes
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
#!/usr/bin/env python3
"""Run pytest and save output to file."""
import subprocess
import sys
import os
def main():
os.chdir(r"D:\Project\MSCodeBase")
result = subprocess.run(
[sys.executable, "-m", "pytest", "tests/test_sandbox.py", "-v", "--tb=short"],
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
timeout=120,
creationflags=0
)
with open("test_output.txt", "wb") as f:
f.write(result.stdout or b"")
f.write(f"\nRETURN_CODE={result.returncode}\n".encode())
print(f"pytest done, exit={result.returncode}")
if __name__ == "__main__":
try:
main()
except Exception:
import traceback
traceback.print_exc()
sys.exit(1)