2022-10-29 15:26:28 +00:00
|
|
|
import unittest
|
|
|
|
import requests
|
|
|
|
import time
|
|
|
|
|
2022-10-30 05:22:44 +00:00
|
|
|
|
2022-11-14 10:39:22 +00:00
|
|
|
def run_tests(proc, test_dir):
|
2022-10-30 05:22:44 +00:00
|
|
|
timeout_threshold = 240
|
|
|
|
start_time = time.time()
|
|
|
|
while time.time()-start_time < timeout_threshold:
|
|
|
|
try:
|
|
|
|
requests.head("http://localhost:7860/")
|
|
|
|
break
|
|
|
|
except requests.exceptions.ConnectionError:
|
2022-11-12 12:12:15 +00:00
|
|
|
if proc.poll() is not None:
|
|
|
|
break
|
|
|
|
if proc.poll() is None:
|
2022-11-14 10:39:22 +00:00
|
|
|
if test_dir is None:
|
|
|
|
test_dir = ""
|
|
|
|
suite = unittest.TestLoader().discover(test_dir, pattern="*_test.py", top_level_dir="test")
|
2022-10-30 05:22:44 +00:00
|
|
|
result = unittest.TextTestRunner(verbosity=2).run(suite)
|
|
|
|
else:
|
|
|
|
print("Launch unsuccessful")
|