From 13416802cbdc50cabdea12b54c6d501536554648 Mon Sep 17 00:00:00 2001 From: Game_Time <108236317+RayBytes@users.noreply.github.com> Date: Sun, 20 Aug 2023 16:23:48 +0500 Subject: [PATCH] making tests properly handle exceptions --- tests/__main__.py | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/tests/__main__.py b/tests/__main__.py index 7bc0243..5e0b567 100644 --- a/tests/__main__.py +++ b/tests/__main__.py @@ -92,24 +92,27 @@ def test_api_moderation() -> dict: def test_all(): """Runs all tests.""" + try: + print("Waiting until API Server is started up...") + time.sleep(6) - print("Waiting until API Server is started up...") - time.sleep(6) + print('[lightblue]Running test on API server to check if its running...') + print(test_server()) - print('[lightblue]Running test on API server to check if its running...') - print(test_server()) + print('[lightblue]Running a api endpoint to see if requests can go through...') + print(test_api('gpt-3.5-trubo')) - print('[lightblue]Running a api endpoint to see if requests can go through...') - print(test_api('gpt-3.5-trubo')) + print('[lightblue]Checking if the API works with the python library...') + print(test_library()) - print('[lightblue]Checking if the API works with the python library...') - print(test_library()) + print('[lightblue]Checking if the moderation endpoint works...') + print(test_library_moderation()) - print('[lightblue]Checking if the moderation endpoint works...') - print(test_library_moderation()) - - print('[lightblue]Checking the /v1/models endpoint...') - print(test_models()) + print('[lightblue]Checking the /v1/models endpoint...') + print(test_models()) + except Exception as e: + print('[red]Error: ' + e) + exit(500) if __name__ == '__main__': closedai.api_base = api_endpoint