How to gradually shift current Django unit tests to pytest?

Viewed 73

Currently, I have a Django 1.11 project. It's setup to act solely as an API backend using Django Rest Framework.

I write unit tests using mostly APITestCase from rest_framework.test, TestCase from django.test, and sometimes TestCase from test_plus.

When I execute my tests I typically use commands like

python manage.py test

python manage.py test somemodule.tests.some_test_file.TestClass.specific_test_case

Or the above but with the keepdb flag to shorten the testing time

python manage.py test --keepdb

python manage.py test somemodule.tests.some_test_file.TestClass.specific_test_case --keepdb

How do I shift to using pytest gradually?

By gradually, I mean long term I move to pytest and pytest commands, but in the meantime, the tests already written can still be used in a single commmand because my CICD on CircleCI is still dependent on the tests to pass.

I also use factory-boy if that's relevant.

0 Answers
Related