diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a147e2bf..32a47248 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -41,4 +41,4 @@ jobs: source env/bin/activate lando migrate lando test - pytest src/lando/api + lando tests diff --git a/pyproject.toml b/pyproject.toml index ce83f172..1c2c3f2f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -35,3 +35,6 @@ where = ["src"] [tool.pytest.ini_options] DJANGO_SETTINGS_MODULE = "lando.test_settings" +testpaths = [ + "src/lando/api", +] diff --git a/src/lando/utils/management/commands/tests.py b/src/lando/utils/management/commands/tests.py new file mode 100644 index 00000000..458e2637 --- /dev/null +++ b/src/lando/utils/management/commands/tests.py @@ -0,0 +1,26 @@ +import subprocess + +from django.conf import settings +from django.core.management.base import BaseCommand + +ROOT_DIR = settings.BASE_DIR.parent.parent + + +class Command(BaseCommand): + help = "Run pytest" + + def add_arguments(self, parser): + parser.add_argument( + "--exitfirst", + "-x", + action="store_true", + help="Exit instantly on first error or failed test" + ) + + def handle(self, *args, **options): + command = ["pytest"] + + if options["exitfirst"]: + command.append("-x") + + subprocess.call(command, cwd=ROOT_DIR)