3

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?

Joe
  • 16,328
  • 12
  • 61
  • 75

2 Answers2

3

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
Joe
  • 16,328
  • 12
  • 61
  • 75
1

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

FedeG
  • 106
  • 6
  • While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - [From Review](/review/late-answers/32619218) – Luis Alejandro Vargas Ramos Sep 06 '22 at 17:52
  • Good catch, but the text is very long, I add the commit link: https://github.com/pytest-dev/pytest-django/blob/0be78e9781682dec745be628ec5fc86ef5f8a3e1/docs/faq.rst#how-can-i-use-managepy-test-with-pytest-django. I this link doesn't work, you shouldn't use this module hahahah – FedeG Oct 24 '22 at 22:40