Utilize hatch to run Django tests? #1826
Unanswered
Archmonger
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have a repository that currently utilizes the Django test runner, but I was curious if I could transition to using the hatch runner
hatch test
instead. Django usespytest
under the hood, so in theory it should be possible.To me it seems like there's two "django things" that aren't easily pushed into hatch's workflow
manage.py
file. This file is pretty simple, it sets up the environment variableDJANGO_SETTINGS_MODULE
and then calls the functiondjango.core.management.execute_from_commandline
.manage.py
processes sys args. It adds a whole slew command line arguments to pytest. The most important arg is--settings <NAME>
which allows for testing multiple unique/discrete Django configurations.While I could just wrap all of my Django tests in a classic
pytest
function and directly executesubprocess.run(["python", "manage.py", "test", "..."]
, that doesn't truly run any of the actual tests within Hatch's test runner, so it's a bit moot.Given that Django is one of the biggest web frameworks, is supporting the Django test runner worthwhile to incorporate into Hatch natively?
And if so, this would likely require Hatch to have a light wrapper to "hook into" Django-Land.
The currently existing alternative is either to require all Django users to...
pytest-django
, which is a bit janky.Beta Was this translation helpful? Give feedback.
All reactions