From 59dfe0845d964868e92572c78a420b6d68c46ea4 Mon Sep 17 00:00:00 2001 From: AUTOMATIC <16777216c@gmail.com> Date: Sun, 30 Oct 2022 08:22:44 +0300 Subject: launch tests from launch.py with --tests commandline argument --- test/server_poll.py | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) (limited to 'test/server_poll.py') diff --git a/test/server_poll.py b/test/server_poll.py index 8c0436f8..eeefb7eb 100644 --- a/test/server_poll.py +++ b/test/server_poll.py @@ -2,16 +2,18 @@ import unittest import requests import time -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: - pass -if time.time()-start_time < timeout_threshold: - suite = unittest.TestLoader().discover('', pattern='*_test.py') - result = unittest.TextTestRunner(verbosity=2).run(suite) -else: - print("Launch unsuccessful") + +def run_tests(): + 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: + pass + if time.time()-start_time < timeout_threshold: + suite = unittest.TestLoader().discover('', pattern='*_test.py') + result = unittest.TextTestRunner(verbosity=2).run(suite) + else: + print("Launch unsuccessful") -- cgit v1.2.1