From 982e586e499a6bc30e1961882ba2c14291e71396 Mon Sep 17 00:00:00 2001 From: Ionut Filip Date: Fri, 2 Nov 2018 16:25:55 +0200 Subject: [PATCH] Replaced os.system calls with native python calls --- tests/compose/core/00_create_users.sh | 1 + tests/compose/test.py | 14 +++++++------- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/tests/compose/core/00_create_users.sh b/tests/compose/core/00_create_users.sh index babe307d..fd998a15 100755 --- a/tests/compose/core/00_create_users.sh +++ b/tests/compose/core/00_create_users.sh @@ -1,3 +1,4 @@ echo "Creating users ..." docker-compose -f tests/compose/core/docker-compose.yml exec admin python manage.py admin admin mailu.io password || exit 1 docker-compose -f tests/compose/core/docker-compose.yml exec admin python manage.py user --hash_scheme='SHA512-CRYPT' user mailu.io 'password' || exit 1 +echo "Admin and user successfully created!" \ No newline at end of file diff --git a/tests/compose/test.py b/tests/compose/test.py index a44382a1..7172aab9 100755 --- a/tests/compose/test.py +++ b/tests/compose/test.py @@ -17,7 +17,7 @@ containers = [] # Stop containers def stop(exit_code): print_logs() - os.system("docker-compose -f " + compose_file + " down") + print(os.popen("docker-compose -f " + compose_file + " down").read()) sys.exit(exit_code) # Sleep for a defined amount of time @@ -64,25 +64,25 @@ def print_logs(): #Iterating through docker container inspect list and print logs for container in containers: print(Fore.LIGHTMAGENTA_EX + "Printing logs for: " + Fore.GREEN + container['Name'] + Style.RESET_ALL) - os.system('docker container logs ' + container['Name']) + print(os.popen('docker container logs ' + container['Name']).read()) #Iterating over hooks in test folder and running them def hooks(): print("Running hooks") for test_file in sorted(os.listdir(test_path)): if test_file.endswith(".py"): - os.system("python3 " + test_path + test_file) + print(os.popen("python3 " + test_path + test_file).read()) elif test_file.endswith(".sh"): - os.system("./" + test_path + test_file) + print(os.popen("./" + test_path + test_file).read()) - os.system("python3 tests/compose/email_test.py") + print(os.popen("python3 tests/compose/email_test.py").read()) # Start up containers -os.system("docker-compose -f " + compose_file + " up -d ") +print(os.popen("docker-compose -f " + compose_file + " up -d ").read()) print() sleep() print() -os.system("docker ps -a") +print(os.popen("docker ps -a").read()) print() health_checks() print()