diff --git a/docs/community/contributing.md b/docs/community/contributing.md index 5be0072db..797bf72e3 100644 --- a/docs/community/contributing.md +++ b/docs/community/contributing.md @@ -83,9 +83,9 @@ To run the tests, clone the repository, and then: --- -**Note:** -If your tests require access to the database, do not forget to inherit from `django.test.TestCase`. -For example: +**Note:** if your tests require access to the database, do not forget to inherit from `django.test.TestCase` or use the `@pytest.mark.django_db()` decorator. + +For example, with TestCase: from django.test import TestCase @@ -94,6 +94,16 @@ For example: # Your test code here pass +Or with decorator: + + import pytest + + @pytest.mark.django_db() + class MyDatabaseTest: + def test_something(self): + # Your test code here + pass + You can reuse existing models defined in `tests/models.py` for your tests. ---