aboutsummaryrefslogtreecommitdiff
path: root/test/server_poll.py
diff options
context:
space:
mode:
authorAUTOMATIC1111 <16777216c@gmail.com>2023-01-04 18:39:57 +0300
committerGitHub <noreply@github.com>2023-01-04 18:39:57 +0300
commit37aafdb059fc038df7217a907048f7eb61f0beee (patch)
tree5ddecfd6d96d6bb1fea556a75fff58782ffcec3b /test/server_poll.py
parent4fbdbddc18b21f712acae58bf41740d27023285f (diff)
parenta8eb9e3bf814f72293e474c11e9ff0098859a942 (diff)
Merge branch 'master' into master
Diffstat (limited to 'test/server_poll.py')
-rw-r--r--test/server_poll.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/test/server_poll.py b/test/server_poll.py
new file mode 100644
index 00000000..d4df697b
--- /dev/null
+++ b/test/server_poll.py
@@ -0,0 +1,24 @@
+import unittest
+import requests
+import time
+
+
+def run_tests(proc, test_dir):
+ 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:
+ if proc.poll() is not None:
+ break
+ if proc.poll() is None:
+ if test_dir is None:
+ test_dir = ""
+ suite = unittest.TestLoader().discover(test_dir, pattern="*_test.py", top_level_dir="test")
+ result = unittest.TextTestRunner(verbosity=2).run(suite)
+ return len(result.failures) + len(result.errors)
+ else:
+ print("Launch unsuccessful")
+ return 1