Joe
Joe

Reputation: 16841

Can I still use `manage.py test` after switching to django-pytest?

It'd be good to keep using the convention of using manage.py test to run tests instead of introducing a new command that isn't standard to Django projects.

Writing tests that py.test can consume is wonderfully concise. Can you get the best of both worlds and wire up Django's manage.py test to run those tests?

Upvotes: 3

Views: 923

Answers (2)

FedeG
FedeG

Reputation: 397

You can use custom TEST_RUNNER but you need add it to your code.

Check the FAQ of pytest-django: https://pytest-django.readthedocs.io/en/latest/faq.html#how-can-i-use-manage-py-test-with-pytest-django

Upvotes: 1

Joe
Joe

Reputation: 16841

It doesn't look like there's an out-of-the-box way to do this, so I added a PR to django-pytest to support this.

Add the following to settings.py:

TEST_RUNNER = 'pytest_django.runner.PyTestRunner'

And then you can run

manage.py test

Upvotes: 3

Related Questions