Skip to content

Commit

Permalink
tests: add tests command (bug 1887042)
Browse files Browse the repository at this point in the history
- add tests management command that runs pytest
- invoke command from github workflow
  • Loading branch information
zzzeid committed May 2, 2024
1 parent 8daf480 commit 23e1a84
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,4 @@ jobs:
source env/bin/activate
lando migrate
lando test
pytest src/lando/api
lando tests
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,6 @@ where = ["src"]

[tool.pytest.ini_options]
DJANGO_SETTINGS_MODULE = "lando.test_settings"
testpaths = [
"src/lando/api",
]
26 changes: 26 additions & 0 deletions src/lando/utils/management/commands/tests.py
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit 23e1a84

Please sign in to comment.