From d067fd64beafd821c3b0dbfd6fe2b21658e203ed Mon Sep 17 00:00:00 2001 From: Zeid Zabaneh <2043828+zzzeid@users.noreply.github.com> Date: Fri, 3 May 2024 13:33:25 -0400 Subject: [PATCH] tests: raise command error with exit code if non-zero (bug 1887042) (#54) --- src/lando/utils/management/commands/tests.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/lando/utils/management/commands/tests.py b/src/lando/utils/management/commands/tests.py index c8ca4370..7fd0471e 100644 --- a/src/lando/utils/management/commands/tests.py +++ b/src/lando/utils/management/commands/tests.py @@ -1,7 +1,7 @@ import subprocess from django.conf import settings -from django.core.management.base import BaseCommand +from django.core.management.base import BaseCommand, CommandError ROOT_DIR = settings.BASE_DIR.parent.parent @@ -30,4 +30,6 @@ def handle(self, *args, **options): if options["paths"]: command += options["paths"] - subprocess.call(command, cwd=ROOT_DIR) + exit_code = subprocess.call(command, cwd=ROOT_DIR) + if exit_code: + raise CommandError(f"Pytest exited with exit code {exit_code}")